Returns 0 if the specified string is not a valid identifier or a number other than 0 if the string is a valid identifier.
valid_name(character_expression)
is a character-type column name, variable, or constant expression of char, varchar, nchar or nvarchar type. Constant expressions must be enclosed in quotation marks.
Creates a procedure to verify that identifiers are valid:
create procedure chkname @name varchar(30) as if valid_name(@name) = 0 print "name not valid"
valid_name, a system function, returns 0 if the character_ expression is not a valid identifier (illegal characters, more than 30 bytes long, or a reserved word), or a number other than 0 if it is a valid identifier.
Adaptive Server identifiers can be a maximum of 30 bytes in length, whether single-byte or multibyte characters are used. The first character of an identifier must be either an alphabetic character, as defined in the current character set, or the underscore (_ ) character. Temporary table names, which begin with the pound sign (#), and local variable names, which begin with the at sign (@), are exceptions to this rule. valid_name returns 0 for identifiers that begin with the pound sign (#) and the at sign (@).
For general information about system functions, see “System functions”.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute valid_name.
System procedure sp_checkreswords