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.
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 thatis used by the job. so now i want to update the table as far as march of 2008.-----declare @CustomerDate smalldatetimeSet @customerDate = cast(datediff(d,0,getdate()-1) as smalldatetime)--if customer date is a sunday, run for previous saturday insteadIf DatePart(w,@customerDate) = 1Set @customerdtaeDate = @customerDate - 1 --Check and see if the records already exist, If so delete themIf 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 onesi.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 |
|
|
|
|
|