I am having an issue dropping this function. I am declaring this function within the sp:
Error: There is already an object named 'extract' in the database.
IF OBJECT_ID('[rpt].[MissMatchesReport]') IS NOT NULL
BEGIN
DROP PROCEDURE [rpt].[MissMatchesReport]
END
GO
CREATE procedure [rpt].[MissMatchesReport]
as
IF object_id(N'extract', N'FN') IS NOT NULL
DROP FUNCTION extract
GO
create function [rpt].extract (@fileName varchar(1236))
returns varchar(123)
as
begin
declare @fileINS as integer = 1, @j int
while 1 = 1
begin
SET @j = charindex('\', @fileName, @fileINS)
if @j < 1
break
SET @fileINS = @j + 1
end
return substring(@fileName, @fileINS, LEN(@filename) - @fileins+1)
end
GO
The only reason I am using this function to make changes into a temp table I created. May be I should drop the function at the end of the sp? However, this SP is for a report so I am not sure if I drop the SP at the end of the execution would still keep everything working in SSRS.
I am very new to SSRS and SQL. Any help is appreciated!
Thanks!