CREATE function [dbo].[MidString](@string varchar(100))
RETURNS varchar(100)
as
begin
Declare @strtloc int
Declare @endloc int
declare @result varchar(50)
set @strtloc = charindex('|',@string)+1
set @endloc = charindex('|',substring(@string,@strtloc,len(@string)))-1
if @endloc = -1
begin
set @endloc=len(@string)
end
set @result=substring(@string,@strtloc,@endloc)
return @result
end
No comments:
Post a Comment