Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the column name "source" get rendered in grey in SSMS & VS T-SQL editor?

I have the following simple tSQL to create a table

CREATE TABLE NewsArticles
(id INT NOT NULL IDENTITY(1, 1) PRIMARY KEY,
lastCrawl DATETIME NULL,
snippet NVARCHAR(2083) NULL,
source NVARCHAR(2083) NULL,
title NVARCHAR(2083) NULL,
url NVARCHAR(2083) NULL)

In both Visual Studio 2012 and SQL Server 2012 Management Studio "source" is rendered in grey while the other column names are rendered green in SSMS or black in VS. Why? The word "source" does not appear to be a reserved word in the list of SQL reserved keywords

enter image description here

like image 365
dumbledad Avatar asked Jul 13 '12 10:07

dumbledad


1 Answers

It is a keyword used in MERGE. i.e. WHEN NOT MATCHED BY SOURCE.

The word MATCHED also exhibits the same behaviour in that it gets highlighted grey in the editor.

Neither of these are reserved keywords though so if used as an identifier they do not need to be delimited (unless you find the syntax highlighting distracting).

like image 57
Martin Smith Avatar answered Oct 06 '22 22:10

Martin Smith