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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 archive insert

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2008-10-23 : 14:11:29
Hi i want to insert some data from a select, how would i loop through this select and insert? this is in a stored proc

SELECT *
FROM records
where Date <= dateadd(month,-3,getdate())

loop though and insert to archive table?

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-10-23 : 14:13:18
quote:
Originally posted by craigmacca

Hi i want to insert some data from a select, how would i loop through this select and insert? this is in a stored proc

SELECT * into Archive
FROM records
where Date <= dateadd(month,-3,getdate())


loop though and insert to archive table?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-23 : 14:27:49
if Archive table is already present
INSERT INTO Archive 
SELECT field1,field2,...
FROM records
where Date <= dateadd(month,-3,getdate())
Go to Top of Page
   

- Advertisement -