The AzureSQLMaintenance script can take some time to execute. Because of that, I would like to be able to interrupt the execution. In SQL Management Studio you can easily do this with the 'Cancel Executing Query` button.
From code I tried it with calling .Cancel() (of the SqlCommand) after 5 seconds but this didn't work. After some investigation I found at that it was because in the script the with nowait is used, which causes that a .Cancel() does not work (which is also commented in comment https://stackoverflow.com/a/24834029)
When I remove all the with nowait from the script, the .Cancel() works perfectly.
Yes, it is safe, the nowait is there to help prompting the message in real time when using SSMS
if you use code then yes, you can safely remove the nowait hint
The AzureSQLMaintenance script can take some time to execute. Because of that, I would like to be able to interrupt the execution. In SQL Management Studio you can easily do this with the 'Cancel Executing Query` button.
From code I tried it with calling
.Cancel()
(of theSqlCommand
) after 5 seconds but this didn't work. After some investigation I found at that it was because in the script thewith nowait
is used, which causes that a.Cancel()
does not work (which is also commented in comment https://stackoverflow.com/a/24834029)When I remove all the
with nowait
from the script, the.Cancel()
works perfectly.Is it safe to remove all the
with nowait
?