Remove First and last comma from string in SQl
Remove First and last comma from string in SQl
declare @Str nvarchar(max)=',kandy,'
if(right(rtrim(@Str),1) = ',')
begin
set @Str= substring(rtrim(@Str),1,len(rtrim(@Str))-1)
end
if(left(ltrim(@Str),1) = ',')
begin
set @Str=Substring(@Str, 2, (len(@Str)))
end
select @Str
Comments
Post a Comment