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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Spinning one variable into many.

Author  Topic 

pug2694328
Posting Yak Master

166 Posts

Posted - 2006-02-16 : 11:30:17
I'm trying to convert a single variable with names delimited by spaces each into a separate variable.

In other platforms I've used the LOCATE function along with substring, but it doesn't seem to be available in SQL Server.

Example:
DECLARE @LIST VARCHAR(200)

SET @LIST = 'NAME1 NAME2 NAME3'

I'd like to either have them in a table:

NAME
NAME1
NAME2
NAME3

or even better in separate dynamically DECLAREd globals (I can get them there from a table of course):
@NAME1 = 'NAME1'
@NAME2 = 'NAME2'
@NAME3 = 'NAME3'

Any Ideas?


RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-02-16 : 11:33:58
Use a Splitter function, search this site and you'll find a few..
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-16 : 12:16:00
See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=split

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-17 : 02:27:42
Also refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

Madhivanan

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

pug2694328
Posting Yak Master

166 Posts

Posted - 2006-02-17 : 10:17:59
Thanks!
Go to Top of Page
   

- Advertisement -