Following SQL-Script is saved in a file:
WHILE @@rowcount > 0
BEGIN
DELETE TOP(100) t1
WHERE name >= 20000
END
For executing in my software, I read the file and then execute the script by following method:
private static void CreateCommand(string queryString, string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
So now my problem is that the script isn't executed correctly on the MSSQL server, the entries still exist. There are no exceptions at all.
If I run the script in Microsoft SQL Server Management Studio, the script is being executed without any problems.
What can cause this issue?