The regex described in the link should be:
var regex = new Regex(@"^[p{L}_][p{L}p{N}@$#_]{0,127}$");
Note that in general you'll have to embed the name of the table in [...]
, because of the rule 3 (so SELECT * FROM [SET]
is a valid query, because, while SET
is a reserved keyword, you can "escape" it with the [...]
)
Note that in the linked page the rule is incomplete:
From https://msdn.microsoft.com/en-us/library/ms175874.aspx
- The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words. 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. The words that are reserved depend on the database compatibility level. This level can be set by using the ALTER DATABASE statement.
And they forgot: https://msdn.microsoft.com/en-us/library/ms174979.aspx
Is the name of the new table. Table names must follow the rules for identifiers. table_name can be a maximum of 128 characters, except for local temporary table names (names prefixed with a single number sign (#)) that cannot exceed 116 characters.
The rule that I've written is for "full" tables, not for temporary tables, and doesn't include schema name.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…