dotnet0824
asked on
convert to SQL Server loop
Hi,
I have this code which has to be written in SQL Server stored Proc . Basically stored proc accepts
StartDate and EndDate and Calcuates the days and loops thru the end of the date and runs the select statement .
S = DateDiff("d", varStartDate, varEndDate - 1)
If s > 0 Then
For i = 1 To s
Select * from tblBank where bankID = 1 and date = dateAdd("d",s,varstartdate )
and bankID = varbankID
I have this code which has to be written in SQL Server stored Proc . Basically stored proc accepts
StartDate and EndDate and Calcuates the days and loops thru the end of the date and runs the select statement .
S = DateDiff("d", varStartDate, varEndDate - 1)
If s > 0 Then
For i = 1 To s
Select * from tblBank where bankID = 1 and date = dateAdd("d",s,varstartdate
and bankID = varbankID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks a lot mwvisa.. I posted a query to add records to temp table if you could help.
You are welcome.
(seems like you are adding a day at beginning and end, so you technically can just input startdate one day later and end date one day sooner -- but coded per loop above)
Open in new window