Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Name ,Type Words turns blue color in query window


Name ,Type Words turns blue color in query window

Author
Message
jchandramouli
jchandramouli
SSC-Enthusiastic
SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)SSC-Enthusiastic (118 reputation)

Group: General Forum Members
Points: 118 Visits: 145
Hi,

Whenever i type the words NAME, TYPE, STATUS in the query window it automatically turns blue. Like: select UID,NAME,TYPE,STATUS,Department FROM My_Table. In this query, except the column Department everythign truns blue. Do anyone know the reason.

Please Do Reply Me Your Answers. Thanks.

"I Love Walking In The Rain So No One Can See Me Crying ! " ~ Charlie Chaplin
GilaMonster
GilaMonster
SSC Guru
SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)

Group: General Forum Members
Points: 74488 Visits: 44977
They are SQL reserved words. Hence management studio highlights them as such.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Grant Fritchey
Grant Fritchey
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29676 Visits: 32488
And best practices dictate that you don't use them in user defined tables. Nothing prevents you from doing it, but it's generally considered poor design and can, in some cases, lead to problems.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Mauve
Mauve
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1570 Visits: 2053
GilaMonster (12/22/2008)
They are SQL reserved words. Hence management studio highlights them as such.

Not exactly. Since when is UID a reserved word? Search for UID in BOL and see what you get. It is the name of a column in some of the system tables and an abbreviation for "User ID" in connection strings.

They ARE NOT SQL Server 2005 reserved keywords. Reserved keywords: http://technet.microsoft.com/en-us/library/ms189822(SQL.90).aspx If they were SQL reserved words they would not be able to be used in the OP's query unless they were quoted.

They are various keywords that have been subjectively chosen by Microsoft and placed into a list within the query editor syntax coloring file.

I've been using NAME, TYPE, STATUS as column names for decades in my relational databases. But one should always check for reserved words and not use them as object names. However, there is no guarantee that any database vendor will not use some term in the future as a "reserved keyword".


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
JustMarie
JustMarie
Right there with Babe
Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)

Group: General Forum Members
Points: 793 Visits: 1234
Enclose them in square brackets and SQL syntax won't format them blue.
Mauve
Mauve
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1570 Visits: 2053
MrsPost (12/23/2008)
Enclose them in square brackets and SQL syntax won't format them blue.

Or...
1. Just ignore the coloring
2. Change the coloring to be all the same color. Under Tools / Options / Environment / Fonts and Colors


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)SSC Guru (51K reputation)

Group: Administrators
Points: 51588 Visits: 19005
That's weird, did it for me as well. And those shouldn't be reserved words. My guess is someone at MS thinks they are and included them in an XML file that determines what is colored as what.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
J-440512
J-440512
SSChasing Mays
SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)

Group: General Forum Members
Points: 615 Visits: 949
Change the coloring to be all the same color.

Wut ??

Highlighting keywords is a valuable assistance provided by the system. A typo in a keyword or failing to add a space between the keyword and a follow-up name will be made immediately obvious. Incomplete strings (missing an apostrophe are also made obvious).

As for table names or column that are the same as reserved keywords. Well, I also would prefer to be advised about that. Note that over the course of time, a perfectly innocent name may become a reserved keyword, so yes, you can avoid using EXISTING keywords but unless you use a foreign language you can never be 100 % sure this will never happen.

Try to avoid prefixing columns with "col". This only serves to reduce legibility of the code and, in the specific case of a column holding an identification, labeling the column colID instead of ID does not help you - colid is also a keyword recognized by the system.

The color is there to tell you something. Turning it off it akin to burying your head in the sand to avoid seeing what you do not want to see. And are you going to force everybody else in your outfit to neutralize the coloring so that a minor issue such as a column or table name shown off as a reserved keyword remains hidden ?
Mauve
Mauve
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1570 Visits: 2053
J (12/23/2008)
Change the coloring to be all the same color.

Wut ??

Highlighting keywords is a valuable assistance provided by the system. A typo in a keyword or failing to add a space between the keyword and a follow-up name will be made immediately obvious. Incomplete strings (missing an apostrophe are also made obvious).

As for table names or column that are the same as reserved keywords. Well, I also would prefer to be advised about that. Note that over the course of time, a perfectly innocent name may become a reserved keyword, so yes, you can avoid using EXISTING keywords but unless you use a foreign language you can never be 100 % sure this will never happen.

Try to avoid prefixing columns with "col". This only serves to reduce legibility of the code and, in the specific case of a column holding an identification, labeling the column colID instead of ID does not help you - colid is also a keyword recognized by the system.

The color is there to tell you something. Turning it off it akin to burying your head in the sand to avoid seeing what you do not want to see. And are you going to force everybody else in your outfit to neutralize the coloring so that a minor issue such as a column or table name shown off as a reserved keyword remains hidden ?

It was only a suggestion for the OP if they are bothered by the coloring.

As for me, I just ignore the erroneous "reserved word" (sic) colorization. E.g., since when is "colid" a reserved word? (BTW, "colid" is not highlighted as a keyword on my system).

I suspect that the "keyword" list includes every column in every one of the system tables. Which would be totally wrong.

As for "correctness" of the reserved words, the following works fine in SQL Server 2005:
CREATE TABLE NAME (STATUS INT, UID UNIQUEIDENTIFIER);


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
J-440512
J-440512
SSChasing Mays
SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)SSChasing Mays (615 reputation)

Group: General Forum Members
Points: 615 Visits: 949
If a user is bothered by the color itself, he might as well use a black and white monitor... I think the OP was more concerned as to the implications of the system highlighting something.

As for reserved keywords, even thought SQL Server has no issues with it, such usage is flagged by Embarcadero ...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search