Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi...I have one more question....

 

Right now, I have a column DLoc in table T1. The DLoc currently has string values separated by a comma...like,

 

T1

======

ID -> 2

DLoc -> Dallas, Boston, Chicago

 

ID is the primary key

==================

 

Now, I want to create a table T2 that has two columns whose values are like this (obtained from T1):

 

T2

======

ID -> 2

Loc -> Dallas

ID -> 2

Loc -> Boston

ID -> 2

Loc -> Chicago

 

(ID,Loc) is the primary key

====================

 

Any ideas on what is the best way to do this??

 

~SJ

  • *Experts*
Posted

Is this a one time update (I hope)?

 

You could write some ADO.NET code to loop through each row and parse the string, inserting new records. Or you could use a cursor in SQL Server to do the same thing, thought string parsing and cursors are not SQL Server's strong point (slow and harder to write than "normal" SQL).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...