Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Small Doubt

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2011-11-03 : 05:46:51
Hi all,

I have a small Query
Declare @test VARCHAR(1000);
After some select this @test contains values like ';test1;test2;test3;'

i want to get answer like
'test1;test2;test3;' ....only need to remove first ;

please help ASAP

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-11-03 : 06:00:23
STUFF() is your friend


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-03 : 06:04:35
select case when @test like ';%' then substring(@test,2,len(@test)) else @test end

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-11-03 : 06:07:10
quote:
Originally posted by madhivanan

select case when @test like ';%' then substring(@test,2,len(@test)) else @test end

Madhivanan

Failing to plan is Planning to fail


I mean using STUFF() while building the value of @test...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -