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 |
Kalpa
Starting Member
9 Posts |
Posted - 2008-08-10 : 05:20:05
|
i need to insert data from table A to table B and only after insertion i have to delete the same data from table A.Afetr insertion i need to check the insertion status and then only i need to delete.Please suggest me how to do it in Sql Server 2005 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-10 : 05:36:24
|
use OUTPUT clauseDECLARE @INSERTED_IDS(PKCol int)INSERT INTO TableBOUTPUT INSERTED.PKCol INTO @INSERTED_IDSSELECT columnsFROM TableADELETE aFROM TableA aINNER JOIN @INSERTED_IDS iON i.PKCol=a.PKCol Here PKCol is the primary key column of tableA (i'm assuming its f type integer else change datatype in table variable) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|