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)
 store procedure to run for consequent days

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2009-04-02 : 15:04:45
Hi

i table say table1 that gets updated by a job on daily basis.

now i have added a new part in the sql code of the stored procedure that
is used by the job. so now i want to update the table as far as march of 2008.

-----


declare @CustomerDate smalldatetime
Set @customerDate = cast(datediff(d,0,getdate()-1) as smalldatetime)

--if customer date is a sunday, run for previous saturday instead
If DatePart(w,@customerDate) = 1
Set @customerdtaeDate = @customerDate - 1


--Check and see if the records already exist, If so delete them
If Exists (Select null from dt..table1 where customerdate = @customerDate)
Delete from table1 where DateOfcustomer = @customerDate

----- ths is the logic that already exists in the sp.

what i need now is if i set a particular date the sp should execute for each day on its own there by deleting old rows and inserting new ones

i.e say if i set customerdate='03/03/2008' it should run from that date to present date..

is it posible.

thanks in advance

dsindo
Starting Member

45 Posts

Posted - 2009-04-02 : 20:32:33
use between on the where clause.

where customerdate between @from_date and @to_date
Go to Top of Page
   

- Advertisement -