My code requires two loops, the first is looping through timebands (which is OK) the second moving the @startdate+1 until @enddate
This is the first loop, I've been trying to add a second (@startdate) loop without success (using WHILE @startdate<= @enddate)
my code....
set @timeband = @starttime
WHILE @timeband <= @endtime
begin
UPDATE tblTempAllowance SET bkdexception = (SELECT SUM(tblTempHol.bkdexception)
FROM tblTempHol WHERE timeband=left(convert(char(25), @timeband, 8),5) and Allowancedate= @startdate)
WHERE timeband=left(convert(char(25), @timeband, 8),5) and Allowancedate=@startdate
set @timeband = dateadd(mi, 30, @timeband)
end
Can anyone help me with the syntax??
This is the first loop, I've been trying to add a second (@startdate) loop without success (using WHILE @startdate<= @enddate)
my code....
set @timeband = @starttime
WHILE @timeband <= @endtime
begin
UPDATE tblTempAllowance SET bkdexception = (SELECT SUM(tblTempHol.bkdexception)
FROM tblTempHol WHERE timeband=left(convert(char(25), @timeband, 8),5) and Allowancedate= @startdate)
WHERE timeband=left(convert(char(25), @timeband, 8),5) and Allowancedate=@startdate
set @timeband = dateadd(mi, 30, @timeband)
end
Can anyone help me with the syntax??