Is there anyway to optimize this function:
CREATE function strip(@para varchar(110))
returns varchar(110)
as
begin
declare @i varchar(110)
if charindex('/',@para) > 0
set @i = left(@para,charindex('/',@para)-1)
else
Set @i = @para
return @i
end
The objective is to strip any characters after and including the '/' - e.g 'test/query' should return 'test' and any string not having the '/' character should be left as is
CREATE function strip(@para varchar(110))
returns varchar(110)
as
begin
declare @i varchar(110)
if charindex('/',@para) > 0
set @i = left(@para,charindex('/',@para)-1)
else
Set @i = @para
return @i
end
The objective is to strip any characters after and including the '/' - e.g 'test/query' should return 'test' and any string not having the '/' character should be left as is