Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
1  
All I can think of is the SSRS Lookup() function (msdn.microsoft.com/en-us/library/ee210531.aspx). Good question. +1 –  Thomas Stringer Aug 17 '12 at 3:32
    
@Shark nice find, but I would expect other functions there to follow similar rules, but they don't highlight in SSMS, e.g. COUNTDISTINCT, COUNTROWS and RUNNINGVALUE should work the same way. –  Aaron Bertrand Aug 17 '12 at 3:39

1 Answer 1

up vote 8 down vote accepted

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...

enter image description here

...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

enter image description here

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
';

enter image description here

(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.

share|improve this answer
2  
I forgot about those! I ran across your Connect submission a while back. –  ErikE Aug 17 '12 at 4:44
    
By the way, "INSTEAD" kind of makes sense since triggers can be INSTEAD OF UPDATE. But it's not a reserved word... –  ErikE Aug 20 '12 at 20:51
    
@ErikE I highlighted "instead" because it is a keyword, just not on the list (another shred of evidence that it is grossly out of date). –  Aaron Bertrand Aug 21 '12 at 18:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.