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
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
Try like below
DECLARE @str as nvarchar(4000)
set @str= 'SELECT ' + replace( '1,2,3,4,5',',',' UNION SELECT ')
EXEC sp_executesql @str
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.