VS.NET- VB.NET - Check for reserved SQL Words

Sql server 2000 ArrayList of reserved words

Synopsis:

Here is a quick and easy way to check any table or field / column names against reserved words in MS SQL. It is simply an arraylist intialized using an array which can be checked for reserved words.

Examples:

		
Public SQLReserved() As String = {"ADD", "EXCEPT", "PERCENT", _
                "ALL", "EXEC", "PLAN", "ALTER", "EXECUTE", "PRECISION", _
                "AND", "EXISTS", "PRIMARY", "ANY", "EXIT", "PRINT", _
                "AS", "FETCH", "PROC", "ASC", "FILE", "PROCEDURE", _
                "AUTHORIZATION", "FILLFACTOR", "PUBLIC", _
                "BACKUP", "FOR", "RAISERROR", "BEGIN", "FOREIGN", "READ", _
                "BETWEEN", "FREETEXT", "READTEXT", "BREAK", "FREETEXTTABLE", _
                "RECONFIGURE", "BROWSE", "FROM", "REFERENCES", _
                "BULK", "FULL", "REPLICATION", "BY", "FUNCTION", "RESTORE", _
                "CASCADE", "GOTO", "RESTRICT", "CASE", "GRANT", "RETURN", _
                "CHECK", "GROUP", "REVOKE", "CHECKPOINT", "HAVING", "RIGHT", _
                "CLOSE", "HOLDLOCK", "ROLLBACK", "CLUSTERED", "IDENTITY", _
                "ROWCOUNT", "COALESCE", "IDENTITY_INSERT", "ROWGUIDCOL", _
                "COLLATE", "IDENTITYCOL", "RULE", "COLUMN", "IF", "SAVE", _
                "COMMIT", "IN", "SCHEMA", "COMPUTE", "INDEX", "SELECT", _
                "CONSTRAINT", "INNER", "SESSION_USER", "CONTAINS", "INSERT", _
                "SET", "CONTAINSTABLE", "INTERSECT", "SETUSER", _
                "CONTINUE", "INTO", "SHUTDOWN", "CONVERT", "IS", "SOME", _
                "CREATE", "JOIN", "STATISTICS", "CROSS", "KEY", "SYSTEM_USER", _
                "CURRENT", "KILL", "TABLE", "CURRENT_DATE", "LEFT", "TEXTSIZE", _
                "CURRENT_TIME", "LIKE", "THEN", "CURRENT_TIMESTAMP", _
                "LINENO", "TO", "CURRENT_USER", "LOAD", "TOP", _
                "CURSOR", "NATIONAL", "TRAN", "DATABASE", "NOCHECK", _
                "TRANSACTION", "DBCC", "NONCLUSTERED", "TRIGGER", _
                "DEALLOCATE", "NOT", "TRUNCATE", "DECLARE", "NULL", "TSEQUAL", _
                "DEFAULT", "NULLIF", "UNION", "DELETE", "OF", "UNIQUE", _
                "DENY", "OFF", "UPDATE", "DESC", "OFFSETS", "UPDATETEXT", _
                "DISK", "ON", "USE", "DISTINCT", "OPEN", "USER", _
                "DISTRIBUTED", "OPENDATASOURCE", "VALUES", _
                "DOUBLE", "OPENQUERY", "VARYING", "DROP", "OPENROWSET", _
                "VIEW", "DUMMY", "OPENXML", "WAITFOR", "DUMP", "OPTION", _
                "WHEN", "ELSE", "OR", "WHERE", "END", "ORDER", "WHILE", _
                "ERRLVL", "OUTER", "WITH", "ESCAPE", "OVER", "WRITETEXT"}
    Public sqlReservedList As New ArrayList(SQLReserved)
Example of Use:
If sqlReservedList.Contains(strVar.ToUpper) Then
	msgbox(strVar & " is a reserved word.")
End if
About this page: