This will provide you with stub to work on. If you want precise code post your tale structure with some sample data.CREATE PROC WebOrderEntryASINSERT INTO CUSTOMER (CreditCardNo,other fields...)SELECT CreditCardNo,...FROM Sales Transactions Work tableWHERE OrderType='WEB'AND OrderDate = DATEADD(d,-1,DATEADD(d,DATEDIFF(d,0,GETDATE()),0))DELETE FROM Sales Payment Work and History table t1INNER JOIN Sales Transactions Work table t2ON t2.orderID=t1.OrderIDWHERE t2.OrderType='WEB'AND t2.OrderDate = DATEADD(d,-1,DATEADD(d,DATEDIFF(d,0,GETDATE()),0))GO
make a job to schedule the execution of SP and configue database mail to send confirmation mail if job is success.The steps for configuring sql server agent job can be found here:-[url]http://msdn2.microsoft.com/en-us/library/ms191439.aspx[/url]Also refer link for configuring dbmail:-[url]http://www.databasejournal.com/features/mssql/article.php/3626056[/url]