Error while using While loop

Jan 12 2020 3:32 AM
This query throws error as "
Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'WHERE'." 
 
 
please help to resolve this issue. 
 
DECLARE @Counter INT
SET @Counter=1
DECLARE @devicemaxNumber INT
SET @devicemaxNumber=72;
WHILE ( @Counter <= @devicemaxNumber)
BEGIN
PRINT 'select * from Device'+@counter+ WHERE 'Inverter'+@counter+ .localcol between '2020-01-10 00:00:00' and '2020-01-10 23:59:59'
SET @Counter = @Counter + 1
END
 
 
 

Answers (3)