While connecting to SQL server using SQL Server (jTds) driver I am getting an error for this simple script.
DECLARE @Count INT
WHILE (SELECT COUNT(*) FROM xxxxxx WHERE Instance < '2015-02-28') > 1
DELETE TOP (100) FROM xxxxxx
WHERE Instance < '2015-02-28'
SET @Count = @Count + 1
IF @Count % 100
SELECT 'DELETED', @Count * 100, 'LEFT', COUNT(*) FROM xxxxxx WHERE Instance < '2015-02-28'
The error is
[S1000] An expression of non-boolean type specified in a context where a condition is expected, near 'BEGIN'.
I have tried to change the condition in multiple different ways.
Normally I would do
WHILE EXISTS(SELECT 1 FROM xxxxxx WHERE Instance < '2015-02-28')
That failed so tried the above.
Here is MS description of WHILE loop
Here is T-SQL standard description of WHILE loop
Normally I would use set based commands but I am trying to limit the amount and duration of locks required during delete.
This in build #DB-143.1411
This type of operation worked fine in earlier versions of 0xDB0
Any suggestions on how to create the the WHILE condition?