Link to home
Start Free TrialLog in
Avatar of jsullivan
jsullivan

asked on

SQL Reserved Word list

Is there a system table in Microsoft SQL Server 6.5 which lists all the Reserved Words?  I am writing an app which will allow the user to define the column names of a view.  I want to check to make sure that they are not trying to name a column with a reserved word like 'SELECT' or 'TABLE'.  As far as I can tell, there is no table which lists the reserved words.  I may have to create my own reference table.
Avatar of vijayakumar
vijayakumar

There is no table which lists the reserved keywords but i think its easy to build with a little bit of effort. But if you want to allow the reserved word to be either a column name or a table name, you can do that. I am givig an example here.

SET QUOTED_IDENTIFIER on
go
create table "table"
( "select"  char(40), "update" char(30) );

Whn QUOTED_IDENTIFIER s turned on, strings  with double quotation will not be evalualted or checked against keywords. But this is not a good practice and its better to avoid.

Avatar of jsullivan

ASKER

Thanks for your input.  I knew about the quoted identifier approach, but we did not want to use that method.
ASKER CERTIFIED SOLUTION
Avatar of tomook
tomook

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the list.  I'm also going to add the list of words which SQL Server has reserved for future possible use.  These are:

 ABSOLUTE
 ACTION
 ALLOCATE
 ARE
 ASSERTION
 AT
 AUTHORIZATION
 BOTH
 CASCADE
 CASCADED
 CAST
 CATALOG
 CHAR_LENGTH
 CHARACTER
 CHARACTER_LENGTH
 COLLATE
 COLLATION
 COLUMN
 CONNECT
 CONNECTION
 CONSTRAINTS
 CORRESPONDING
 DATE
 DAY
 DEFERRABLE
 DEFERRED
 DESCRIBE
 DESCRIPTOR
 DIAGNOSTICS
 DISCONNECT
 DOMAIN
 END_EXEC
 ESCAPE
 EXCEPTION
 EXPIREDATE
 EXTERNAL
 EXTRACT
 FALSE
 FILE
 FIRST
 FULL
 GET
 GLOBAL
 HOUR
 IMMEDIATE
 INITIALLY
 INNER
 INPUT
 INTERVAL
 JOIN
 LAST
 LEADING
 LEFT
 LOCAL
 MATCH
 MINUTE
 MONTH
 NAMES
 NATIONAL
 NATURAL
 NCHAR
 NEXT
 NO
 OCTET_LENGTH
 OUTER
 OUTPUT
 OVERLAPS
 PAD
 PARTIAL
 POSITION
 PRESERVE
 PRIOR
 PRIVILEGES
 RELATIVE
 RESTRICT
 RETAINDAYS
 RIGHT
 ROWS
 SCHEMA
 SECOND
 SESSION
 SIZE
 SPACE
 SQLSTATE
 TIME
 TIMESTAMP
 TIMEZONE_HOUR
 TIMEZONE_MINUTE
 TRAILING
 TRANSLATE
 TRANSLATION
 TRUE
 UNKNOWN
 USAGE
 USING
 VALUE
 VOLUME
 WORK
 WRITE
 YEAR
 ZONE

A few of these are in the list of new words for SQL 7.

Thanks.