0

I need to explode comma seperated string for reporting purpose in mssql, what i exactly need is to convert string likr 1,2,3,4,5,6,7,8,9 as below

column
1
2
3
4
5
6
7
8
9

I have been helpless so far now, its spoiling my weekend , help me out

4

2 回答 2

0

Try like below

DECLARE @str as nvarchar(4000) 
set @str=  'SELECT ' + replace( '1,2,3,4,5',',',' UNION SELECT ')
EXEC sp_executesql @str
于 2012-05-26T03:20:15.813 回答
-2

No you can't directly do this. You need to create function which returns the table accepting as string. You need create a table variable , add values to that and return.

于 2012-05-26T03:16:15.847 回答