I've tried this script, but it will only work if there are no spaces in the db_name. We have a database named Mediabin Repository and when I run this script, I'll get the following error:
"Msg 911, Level 16, State 1, Line 1"
"Could not locate entry in sysdatabases for database 'MediaBin'. No entry found with that name. Make sure that the name is entered correctly."
What is the correct way to run this script when there are spaces in the database name?