Click here to Skip to main content
15,887,746 members
Home / Discussions / Database
   

Database

 
AnswerRe: Moving Data Between Tables Pin
Wendelius26-Oct-08 1:29
mentorWendelius26-Oct-08 1:29 
GeneralRe: Moving Data Between Tables Pin
Meysam Mahfouzi26-Oct-08 2:34
Meysam Mahfouzi26-Oct-08 2:34 
GeneralRe: Moving Data Between Tables Pin
Wendelius26-Oct-08 2:39
mentorWendelius26-Oct-08 2:39 
AnswerRe: Moving Data Between Tables Pin
PIEBALDconsult29-Oct-08 5:38
mvePIEBALDconsult29-Oct-08 5:38 
GeneralRe: Moving Data Between Tables Pin
Meysam Mahfouzi29-Oct-08 10:20
Meysam Mahfouzi29-Oct-08 10:20 
GeneralRe: Moving Data Between Tables Pin
PIEBALDconsult29-Oct-08 11:39
mvePIEBALDconsult29-Oct-08 11:39 
GeneralRe: Moving Data Between Tables Pin
Meysam Mahfouzi29-Oct-08 17:21
Meysam Mahfouzi29-Oct-08 17:21 
GeneralRe: Moving Data Between Tables Pin
PIEBALDconsult30-Oct-08 4:28
mvePIEBALDconsult30-Oct-08 4:28 
Maysam Mahfouzi wrote:
I can't rely on old VARCHAR values to calculate new ID


No, you're using auto-increment for the new IDs, right?


ID,ParentId,OldID,OldParentId,Description (or whatever it is)

INSERT INTO NewTable (OldID,OldParentId,Description) SELECT * FROM OldTable (add an ORDER BY clause if desired)

And you get all new IDs. You also have the original mappings. For any row with non-null OldParentId, match it to the row with that OldID to get the (new) ID to put in the (new) ParentID.

Something like this:

UPDATE NewTable 
SET ParentId=B.ID
FROM NewTable A
INNER JOIN NewTable B
ON A.OldParentID=B.OldID


(I think I'll go test that now.)

Then remove the OldID and OldParentID columns (if desired).
GeneralRe: Moving Data Between Tables Pin
Meysam Mahfouzi30-Oct-08 8:12
Meysam Mahfouzi30-Oct-08 8:12 
GeneralRe: Moving Data Between Tables Pin
PIEBALDconsult30-Oct-08 10:26
mvePIEBALDconsult30-Oct-08 10:26 
GeneralRe: Moving Data Between Tables Pin
Meysam Mahfouzi31-Oct-08 19:59
Meysam Mahfouzi31-Oct-08 19:59 
Questionproblem to start a sql server service manager Pin
sathyan_829425-Oct-08 2:19
sathyan_829425-Oct-08 2:19 
AnswerRe: problem to start a sql server service manager Pin
Wendelius25-Oct-08 2:24
mentorWendelius25-Oct-08 2:24 
GeneralRe: problem to start a sql server service manager Pin
sathyan_829425-Oct-08 2:51
sathyan_829425-Oct-08 2:51 
GeneralRe: problem to start a sql server service manager Pin
Wendelius25-Oct-08 4:32
mentorWendelius25-Oct-08 4:32 
QuestionEasier way to clip numeric values to min/max boundaries Pin
ScruffR24-Oct-08 15:21
ScruffR24-Oct-08 15:21 
AnswerRe: Easier way to clip numeric values to min/max boundaries Pin
Syed Mehroz Alam24-Oct-08 17:48
Syed Mehroz Alam24-Oct-08 17:48 
GeneralRe: Easier way to clip numeric values to min/max boundaries Pin
ScruffR26-Oct-08 22:49
ScruffR26-Oct-08 22:49 
GeneralRe: Easier way to clip numeric values to min/max boundaries Pin
PIEBALDconsult29-Oct-08 5:45
mvePIEBALDconsult29-Oct-08 5:45 
AnswerRe: Easier way to clip numeric values to min/max boundaries Pin
Wendelius24-Oct-08 21:24
mentorWendelius24-Oct-08 21:24 
QuestionProbleum in SQL Query Pin
anoopazgar24-Oct-08 1:01
anoopazgar24-Oct-08 1:01 
AnswerRe: Probleum in SQL Query Pin
Ashfield24-Oct-08 1:36
Ashfield24-Oct-08 1:36 
GeneralRe: Probleum in SQL Query Pin
Paul Conrad24-Oct-08 4:49
professionalPaul Conrad24-Oct-08 4:49 
AnswerRe: Probleum in SQL Query Pin
Jason Lepack (LeppyR64)24-Oct-08 1:46
Jason Lepack (LeppyR64)24-Oct-08 1:46 
AnswerRe: Probleum in SQL Query Pin
Blue_Boy24-Oct-08 8:33
Blue_Boy24-Oct-08 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.