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:
Domains
lights up in green
Description
lights up in blue
Server
lights up in blue
Instead
lights up in blue
RC2
and RC4
light 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.
COUNTDISTINCT
,COUNTROWS
andRUNNINGVALUE
should work the same way.