Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to pivot semi-colon separated names 1

Status
Not open for further replies.

HoustonGuy

Programmer
Jun 29, 2000
165
0
0
US
I have this list:

Name1;Name2;Name3; etc.

And need to write code to pivot it to this:

Name1
Name2
Name3

Any suggestions?
 
Vague question, so one of the answers: replace [tt];[/tt] with Enter / hard return

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
To be more specific, I need to create a column populated with names that are semi-colon delimited.
I do have this, but would like to insert into separate rows into a single column.

SQL:
DECLARE @TestString varchar(max), @NewString varchar(max)

SET @TestString ='Name1111;Name2;GalvestonIsland;Name3;Name33333;Name444;'
SET @NewString =REPLACE ( @TestString , ';' , CHAR(13) )--hard code a new line feed
PRINT @NewString;

I suspect I'll need to iterate through the string, or use SSIS for a quick load into a table.
 
I am thinking this is a limited example any you want to combine multiple items from a table.

Take a look at FOR XML PATH here in the forums and google

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top