yochananrachamim / AzureSQL

129 stars 61 forks source link

Prevent error when current SQL Server version does not support RESUMABLE #42

Open mperdeck opened 4 months ago

mperdeck commented 4 months ago

I want to use your script AzureSQLMaintenance with a version of SQL Server that does not support RESUMABLE.

The script does check for that situation. However, when RESUMABLE is not supported, or parameter @ResumableIndexRebuild = 0, the script adds "RESUMABLE=OFF" to the "ALTER INDEX REBUILD" command.

This causes an error, because my older version of SQL Server doesn't recognize RESUMABLE at all, including "RESUMABLE=OFF"

This pull request changes the code, so when RESUMABLE is not supported, or parameter @ResumableIndexRebuild = 0, it doesn't add "RESUMABLE=OFF". "OFF" is the default anyway for RESUMABLE, so this doesn't change existing behavior when the script runs.

When RESUMABLE is supported, and parameter @ResumableIndexRebuild = 1, it still adds "RESUMABLE=ON"