Hello,
I want this procedure to be executed everyday 2:00 a.m. Also, i want to pass date parameter to the procedure. Suppose today is 28th july, 2010, then i want to pass 27th july, 2:00 am to the procedure. This way i want that all records inserted after 27th july, 2:00 am should be backed up in some other table. This is my procedure.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Alter PROCEDURE spBackupRows
(
@Date datetime
)
AS
BEGIN
Declare @ItemId int, @ItemName varchar(100), @Description varchar(50), @ItemCreatedDateTime datetime
Declare myCursor Cursor FOR
Select * from tblItems Where ItemCreatedDateTime > @Date
Open myCursor
Fetch Next From myCursor INTO @ItemId,@ItemName,@Description,@ItemCreatedDateTime
while @@FETCH_STATUS = 0
Begin
INSERT INTO tblBackUpData
(ItemId,ItemName,Description,ItemCreatedDateTime)
Values (@ItemId,@ItemName,@Description,@ItemCreatedDateTime)
Fetch Next From myCursor INTO @ItemId,@ItemName,@Description,@ItemCreatedDateTime
End
Close myCursor
Deallocate myCursor
END
GO
The problem i face is how do i make this procedure fire automatically? and also pass datetime
parameter to the procedure?
Thanks in advance :)