Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi i want to insert some data from a select, how would i loop through this select and insert? this is in a stored procSELECT *FROM recordswhere 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 procSELECT * into ArchiveFROM recordswhere Date <= dateadd(month,-3,getdate())loop though and insert to archive table?
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 recordswhere Date <= dateadd(month,-3,getdate())