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

Popular posts from this blog

Create and save QR code in asp.net with C#

Change text of RadGrid Header Dynamically

Telerik Radwindow Open on Button Click