October 20, 2005 at 5:00 am
hi
i am having one table like xxx
id name address parent_id
1 ddd mumbai null
2 eee mumbai 1
3 ff mumbai 2
now i want to copy the data from xxx table into yyy, like this
table:yyy
id name address parent_id
4 ddd mumbai null
5 eee mumbai 4
6 ff mumbai 5
here id should not be repeated from xxx
October 20, 2005 at 5:49 am
ASSUMPTION: ID = IDENTITY.
Just run INSERT INTO Table2 ([Name], Address) SELECT ([Name], Address) FROM Table1
Parent_ID will need to be manually recreated (I am thinking)....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
October 20, 2005 at 6:14 am
here id will be the newid and between col1 and col3 there is a parent child relation..can we do though store procedure
October 20, 2005 at 3:13 pm
Nazri,
AFAIK IF you are changing the IDs you will have to create the links the old fashioned way MANUALLY.... unless you can figure out the NEWID and compare it to the OLD ID to determine the DELTA and then run an UPDATE Statement after the initial INSERT....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply