January 13, 2011 at 12:42 am
I want to insert the data from 1 table to another table.Delete first table After inserting the data from first table. like cut and paste.
January 13, 2011 at 3:38 am
January 13, 2011 at 7:50 am
It just has to be a series of TSQL statements. I'd just suggest wrapping it in a transaction so that you know the data was moved successfully prior to deleting it, and that it deleted succesfully prior to assuming that you're all done. Something like this:
BEGIN TRANSACTION
INSERT TableA
(Col1,
Col2)
SELECT b.Col1,
b.Col2
FROM TableB as b
WHERE b.Col3 = 'somevalue';
DELETE TableB AS b
WHERE WHERE b.Col3 = 'somevalue';
COMMIT TRANSACTION
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
June 10, 2011 at 9:55 am
This is exactly what i was looking for myself thanks for the post
__________________________________________________________________________________
Steve J
Jnr Developer
BSc(Hon)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply