We\'re going to provide our clients with a tool that (among other things) creates a new SQL Server database, and I want to be able to do basic validation on the database nam
The rules for identifiers state at the end:
When identifiers are used in Transact-SQL statements, the identifiers that do not comply with these rules must be delimited by double quotation marks or brackets.
By choosing a database name which does not conform to those rules, you have to enclose it always with double quotation marks or brackets.
If the rules for regular identifiers are respected, you may use your database name without quotes/brackets.
The following instructions are ok
CREATE DATABASE [conformingName]
CREATE DATABASE conformingName
CREATE DATABASE [This & That | "Other"]
but not
CREATE DATABASE This & That | "Other"
EDIT:
I agree that this is not how one would understand the linked documentation: What does must comply with the rules for identifiers mean if the rules do not apply anymore as soon as the identifier is enclosed? The point about enclosing non conforming identifiers should be part of the rules.