harsha.bhagat1 (8/29/2008)
I have to receive a text field in which you cannot add any extra ',' anywhere .
If you are receiving the data as a parameter why can't you declare a new variable to add the beginning and ending commas? Like this:
Declare @text varchar(8000)
Set @text = ',' + @parameter + ','
Then you process the @text variable or you can just do this:
Select
Substring(',' + @text + ',', N+1, Charindex(',', ',' + @text + ',', N+1) - n -1)
From
tally
Where
N <= Len(',' + @text + ',') AND
SUBSTRING(',' + @text + ',', N,1) = ',' And
Charindex(',', ',' + @text + ',', N+1) > 0
order by
n
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question