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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-13 : 08:17:57
gurvinder writes "HI
I want to create a stored procedure in sql server.I have 2 tables called orders and orderdetails which contains list of orders.Now i want to move orders which r more than 60 days old to new table called orders2 and orderdetail2. and wants to delete those orders from first tables thats orders and orderdetails.please can anybody make it fast for me
thank you
gary"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-13 : 08:44:21
Create Procedure MoveData as
Insert into orders2 select * from orders where datediff(day,orderdate,getdate())>60
Go
Insert into orderdetails2 select * from orderdetailss where datediff(day,orderdate,getdate())>60
Go
Delete from orders where (day,orderdate,getdate())>60
Go
Delete from orderdetails where (day,orderdate,getdate())>60




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -