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.
| Author |
Topic |
|
Nazri
Starting Member
8 Posts |
Posted - 2005-10-20 : 07:34:05
|
| hii have some problem...how to copy the data from one table to anotherfor exampletable:xxxid name address parentid1 xxx Delhi null2 yyy mumbai 13 zzz Banglore 2now i want to copy the data from xxx table to yyy..all things will be same onle change will be in column1 and column3(column1 will not be same to xxx table) like thistable:yyyid name address parentid4 xxx delhi null5 yyy mumbai 46 zzz Banglore 5with regardsNazri |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-20 : 07:55:26
|
| If id field of yyy table is idenetity thenInsert into yyy(name,address) Select name, address from xxxThen reset your id to max id of xxx + 1 at yyy and run this update queryUpdate yyy set parentid=id-1Refer point 1 here alsohttp://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
Nazri
Starting Member
8 Posts |
Posted - 2005-10-20 : 08:02:15
|
| hi madhivananactually there is parent child relation between id and parentid and in id i am inserting newid..and i want do through stored procedure. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-20 : 09:02:04
|
| Did you try the method I suggested?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|