Need to exit a loop when sql table is empty
Doing a query to determine if a table is empty and when it is I want to exit the do statement. I have tried case statements, Do while, used nulls rather than 0's, and I just can't get it to stop once the table goes empty.
doChkQ.Connection = con
doChkQ.CommandText = ("select top 1 badge from [P].[dbo].[Sub]")
doChk = doChkQ.ExecuteScalar
Do While doChk > 0
// Code to execute
Loop
In the code I delete rows until the table is completely empty and once it is empty I want it to end the do loop.