Skip to content
Advertisement

Fetching Database Name with Space

Thanks for looking into my post. I am trying to run a query across all the database in SQL Server but the cursor is not fetching if the database contains space and the database is online.

Code

Error

Advertisement

Answer

Delimit Identify your object’s name. In normal terms that would be wrapping it with brackets ([]), however, as this appears to be dynamic SQL you should be using QUOTENAME:

But, ideally, don’t use object names that require you to delimit identify your objects.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement