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 |
ann
Posting Yak Master
220 Posts |
Posted - 2006-10-10 : 14:33:29
|
I have a temp table that only ever holds 100 records. What I need to do when I'm done with this table is:1. Copy all the records to another table (append)2. Delete the records from the original table (the ID field of the orig. table is stored in the temp table)3. Delete all the records from this temp table.I can figure out how to do # 2 & 3 via 2 seperate stored procedures, but is there a way I can do all 3 within 1 stored procedure?Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-10-10 : 14:38:37
|
There is no difference between putting the code into separate stored procedures or into one stored procedure, so could you post what you have so far?Tara Kizer |
 |
|
druer
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-10-10 : 15:42:53
|
-- Step 1insert into tblAnother(field1, field2, field3)select field1, field2, field3 from tblTemporary-- Step 2delete from tblOriginal where Id in (select id from tblTemporary)-- Step 3truncate tblTemporary -- or drop #tblTemporary (if it is really a "temp" tableHope it helps,DaltonBlessings aren't so much a matter of "if they come" but "are you noticing them." |
 |
|
|
|
|