SQL Server 2008 - Is the name "Procedure" Reserved?

In SQL Server 2008 I named the table "Procedures"

Whenever I write a query, the word "Procedures" changes to "green", but none of my other table names do. I'm guessing it has something to do with stored procedures that has nothing to do with the table I created.

Can I use the table name in the procedure or change it?

+3


source to share


3 answers


Procedures

It turns green, because it is a directory name sys.procedures

. When I see an element that collides with T-SQL color coding (whether it's reserved or not, and whether it's causing errors today or not), I doubt it's the best name to use.

If I go to a new version of SQL Server and a word suddenly becomes a keyword or a reserved word, there is little that can be done except (a) a complete and painful refactoring, or (b) using square brackets around the name to make sure SQL Server understands it as an identifier. It won't turn green, for example:

SELECT cols FROM dbo.[Procedures];

      



It's not that obvious, but in addition to not lighting up green, it actually insulates you from future compatibility issues if they ever make a Procedures

keyword or a reserved word.

In general, I find it safer to use square brackets around any identifier names that are even within the realm of the possibility of ever becoming a keyword.

+5


source


You should be fine. Procedure (singular) is a reserved word, but Procedures (plural) is not.

Here is a list of all the reserved keywords - SQL reserved keywords



Please note that you are allowed to specify the table what you want. I wouldn't find it best practice to name the table as a reserved keyword, but you can. Keep in mind that you will have to modify your queries slightly if you do this by wrapping the table name in square brackets.

+1


source


You can name your table whatever you want (except that it must follow the rule of identifiers and cannot be more than 128 characters long). If this is a reserved word, you will have to use [TableName]. This is generally not recommended. This could confuse another developer and could cause problems in future updates if it becomes a reserved keyword.

Procedures are not a reserved keyword during a procedure.

Reserved keywords

+1


source







All Articles