Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 description reserved keyword

Author  Topic 

JCollum
Starting Member

6 Posts

Posted - 2008-01-08 : 13:24:57
I'm sure this has been answered before but I couldn't find it.

How come 'Description' is showing as a keyword in sql server 2005 management studio? I don't see Description on the list of any of the keywords here: http://technet.microsoft.com/en-us/library/ms189822.aspx. So I'm confused.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-08 : 13:55:35
To make the "blue" go away, just put square brackets around the object name.

I'm not sure of the answer to your question. But when it comes to naming your sql objects, the first thing you should do is see if your "culture" already has a naming convention set. If not, a good rule of thumb is to make the name descriptive enough so you can tell what the object is without the context of what column it is next to or what table it is in. ie: instead of [code], [description], [id] you should use [StateCode], [businessDescription], [employeeID].



Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-09 : 02:17:38
http://vyaskn.tripod.com/object_naming.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

JCollum
Starting Member

6 Posts

Posted - 2008-01-09 : 20:11:04
The "culture" uses Description as a column name like everywhere, so that's not going to change. The sql works fine with Description not in brackets so that's fine, but I'm just worried that it's going to break someday for some weird reason, because sql sees it as a keyword. At least the Management Studio does....
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-09 : 20:20:03
quote:
Originally posted by JCollum

The "culture" uses Description as a column name like everywhere, so that's not going to change. The sql works fine with Description not in brackets so that's fine, but I'm just worried that it's going to break someday for some weird reason, because sql sees it as a keyword. At least the Management Studio does....


If you add the square backets (as I said before) sql will always treat it as an object name.

Ah! This gives me another opportunity post some silly code I did once. Only to prove my point of course

set nocount on

create table [From]
([Select] varchar(15)
,[group by] varchar(15)
,[Where] varchar(15)
,[Having] varchar(15))
GO

insert [From] values ('Select','From','Group by','Having')

Select [Select],[Group by]
[From],max([having])[Having]
From [From]
Where [Where]='Group by' Group by [Select],[Group by]
Having max([Having])='Having'

GO
drop table [From]


Be One with the Optimizer
TG
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-01-09 : 21:05:50
quote:

Ah! This gives me another opportunity post some silly code I did once. Only to prove my point of course

set nocount on

create table [From]
([Select] varchar(15)
,[group by] varchar(15)
,[Where] varchar(15)
,[Having] varchar(15))
GO

insert [From] values ('Select','From','Group by','Having')

Select [Select],[Group by]
[From],max([having])[Having]
From [From]
Where [Where]='Group by' Group by [Select],[Group by]
Having max([Having])='Having'

GO
drop table [From]


Be One with the Optimizer
TG



Now that's funny, I don't care who ya are...




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

JCollum
Starting Member

6 Posts

Posted - 2008-01-09 : 21:44:27
The question wasn't "How do I get rid of the blue" it was "Why is it blue at all if 'Description' isn't on the list of keywords"?
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-01-09 : 21:55:46
because it is a keyword in certain procedures and functions



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -