SQLUndercover / UndercoverToolbox

A collection of cool and useful tools, procedures and scripts for the discerning DBA
https://sqlundercover.com
MIT License
84 stars 40 forks source link

sp_RestoreScript @SingleUser=1 generates wrong ALTER command #260

Closed rubaboo closed 3 years ago

rubaboo commented 3 years ago

Describe the bug

ALTER DATABASE [dev] SET SINGLE_USER WITH ROLLBACK IMMEDIATE, REPLACE, MOVE 'prod' TO 'd:\data\dev.mdf',MOVE 'prod_log' TO 'd:\log\dev.ldf'

To Reproduce Run sp_RestoreScript with parameters @withMove...=..., @Replace=1, and @SingleUser=1.

Expected behavior

ALTER DATABASE [dev] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Additional context Latest version sp_RestoreScript 1.7

Adedba commented 3 years ago

Thanks for the bug report! I have made a revision which needs some testing on a new branch called #260-sp_RestoreScript-@SingleUser=1-generates-wrong-ALTER-command , Normally @UndercoverDavid maintains sp_restorescript so I will leave this for him to review the changes and ensure he is happy, he may decide to tackle the fix in a different way but for the time being feel free to give this version a go.

Thanks again for taking the time to submit an issue.