问题
I was writing a Stored Procedure
today and Wrote the line:
SELECT pv1.Version FROM depl...
and the word Version
turned blue shown below:
so I assumed it was a reserved word, so did some investigating here:
Reserved Keywords (TRANSACT-SQL)
But could not find the word Version
in the list.
Is Version
a SQL reserved word, and if not why is my word Version
displaying blue? I am using SQL Management Studio 2012
回答1:
As you rightly noted, Version
is not in the official reserved word list. It's just a "feature" of SQL Server Management Studio that is showing it in blue.
There are many words like this. Here's a few more:
DESCRIPTION
SERVER
INSTEAD
There are even some words that show as pink such as LOOKUP
.
回答2:
"Version" is not a SQL Server reserved keyword.
However, it is used in a global variable used to show the OS name & version, SQL Server version, SQL Server patches and hardware attributes of the SQL Server being used.
SELECT @@VERSION
Perhaps the "Version" text turns blue in Transact-SQL because it is known to SQL Server in the context of this global variable. I'm not sure about that, this is just a theory.
回答3:
The short answer - no, it isn't. Here's an SQLFiddle that uses it as a column name in SQL-Server 2014 to prove it.
回答4:
I think you can always if in doubt wrap your column name in brackets to use reserved words as column names:
select p1.[Version] from dpl...
来源:https://stackoverflow.com/questions/30805490/is-version-a-reserved-word-in-transact-sql-shows-blue-but-not-in-reserved-wo