yochananrachamim / AzureSQL

129 stars 61 forks source link

Can I safely remove the `with nowait` from the AzureSQLMaintenance script? #30

Closed gercobrandwijk closed 1 year ago

gercobrandwijk commented 2 years ago

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.

Is it safe to remove all the with nowait?

yochananrachamim commented 1 year ago

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