valid_name

Description

Returns 0 if the specified string is not a valid identifier or a number other than 0 if the string is a valid identifier.

Syntax

valid_name(character_expression)

Parameters

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.

Examples

Example 1

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"

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute valid_name.

See also

System procedure sp_checkreswords