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
 Spliting string with delimiter

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2009-11-03 : 23:31:08
am having a string, and delimiter comma
@mainstring='a,b,c,d',
@delimiter=','
i want to split this string value into array. how to do this in sql

thanks
subha

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-04 : 00:00:03
see

CSVTable
fnParseList



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-11-04 : 00:14:25
@mainstring='a,b,c,d',
@delimiter=','

@mainstring = 'INSERT INTO @temp SELECT '' + @mainstring
replace ',' to ''''' UNION SELECT ''''''
exec(@mainstring)
Select * from @temp


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-04 : 01:22:47
quote:
Originally posted by waterduck

@mainstring='a,b,c,d',
@delimiter=','

@mainstring = 'INSERT INTO @temp SELECT '' + @mainstring
replace ',' to ''''' UNION SELECT ''''''
exec(@mainstring)
Select * from @temp


Hope can help...but advise to wait pros with confirmation...


Hey Ducky, what are you drinking?


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 - 2009-11-04 : 01:42:00
quote:
Originally posted by webfred

quote:
Originally posted by waterduck

@mainstring='a,b,c,d',
@delimiter=','

@mainstring = 'INSERT INTO @temp SELECT '' + @mainstring
replace ',' to ''''' UNION SELECT ''''''
exec(@mainstring)
Select * from @temp


Hope can help...but advise to wait pros with confirmation...


Hey Ducky, what are you drinking?


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


WATER?

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-04 : 01:49:03
LOL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -