patternModerate
Why is "Lookup" colored as a function reserved word in SQL Server?
Viewed 0 times
whysqlcoloredfunctionwordserverlookupreserved
Problem
In SSMS 2208, the identifier "Lookup" is colored hot pink as if it were a function (same color as, say, "Power" or "Convert"). Why?
I cannot find it in the official list of reserved words. Searches on the web seem useless as there are an awful lot of "lookup" terms out there that have nothing to do with my question.
I cannot find it in the official list of reserved words. Searches on the web seem useless as there are an awful lot of "lookup" terms out there that have nothing to do with my question.
Solution
At first I thought it came from Sybase (which is where SQL Server originated of course), which has a lookup function, but this is PowerBuilder-related. And then I checked SQL Server 2000 and it doesn't light up in pink in Query Analyzer...
...if it was legacy from Sybase I would have expected it to be in the list of color-coded words all along. It's possible, I suppose, that the grammar file was updated and that it was omitted "by mistake" in 2000, but I doubt it. It is much more likely that it is colored because it is listed in the T-SQL Language Service as a future compatibility word, or it was thrown into the Language Service in anticipation of being used. (I am waiting on official confirmation of this, and I will share what I can.)
Some other fun examples (I complained about a few of these on Connect back in 2008, but it was closed as Won't Fix) of inappropriate highlighting of words that are also not on the list you cite:
At the time I didn't capture the
Another example you might find interesting; try putting a word like
(This one courtesy of a bug filed by @JonSeigel.)
I've probably filed and commented on a couple of dozen other bugs against Management Studio's syntax highlighting; it certainly isn't perfect. I appreciate that you want to know why but we may not ultimately find out. As you can see from a lot of these Connect items, they usually ignore/defer them, or fix them without much explanation.
...if it was legacy from Sybase I would have expected it to be in the list of color-coded words all along. It's possible, I suppose, that the grammar file was updated and that it was omitted "by mistake" in 2000, but I doubt it. It is much more likely that it is colored because it is listed in the T-SQL Language Service as a future compatibility word, or it was thrown into the Language Service in anticipation of being used. (I am waiting on official confirmation of this, and I will share what I can.)
Some other fun examples (I complained about a few of these on Connect back in 2008, but it was closed as Won't Fix) of inappropriate highlighting of words that are also not on the list you cite:
Domainslights up in green
Descriptionlights up in blue
Serverlights up in blue
Insteadlights up in blue
RC2andRC4light up in blue
At the time I didn't capture the
Lookup or Instead examples, and I'm sure there are some others as well. Though I'm guessing the document you're looking at is not as up to date as it could be either; at the very least, INSTEAD should be on that list since it is a part of T-SQL now (since INSTEAD OF triggers were introduced). I bet there are at least 20 other keywords that have been added for SQL Server 2012 but aren't on that list, too. Quickly scanning there are some notable exclusions that should be there: OFFSET, IIF, FORMAT, etc.Another example you might find interesting; try putting a word like
INSTEAD in a string but on its own line. This runs fine but it doesn't look like it will:SELECT 'foo
INSTEAD
';(This one courtesy of a bug filed by @JonSeigel.)
I've probably filed and commented on a couple of dozen other bugs against Management Studio's syntax highlighting; it certainly isn't perfect. I appreciate that you want to know why but we may not ultimately find out. As you can see from a lot of these Connect items, they usually ignore/defer them, or fix them without much explanation.
Code Snippets
SELECT 'foo
INSTEAD
';Context
StackExchange Database Administrators Q#22655, answer score: 14
Revisions (0)
No revisions yet.