Author |
Topic |
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-08 : 14:19:53
|
I have one column name that is: descriptionwhen i write a query the world lights up with blue, I think I saw someone using [ ] around the word but I no longer remember if this is the way to handle reserve words that have been use as columns names |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-05-08 : 14:21:43
|
Did you try it? Test it out and see what happens! that's the best way to learn. Don't just take the advice of random forum posters as gospel! - Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-08 : 14:21:46
|
Yes.Try first. It must have been shorter period of time to test first...Peter LarssonHelsingborg, Sweden |
 |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-05-08 : 14:28:15
|
I tried both ways and it works, either way, so I am unsure if there is "a recommended way to do it" |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-08 : 14:38:39
|
recommended is not to use reserved words in object names at all. if you must do it, wrap them in square brackets. or use double quotes if you care about ANSI compliance. the square brackets are T-SQL only.also just because a word lights up in SSMS doesn't mean it's reserved. http://www.petefreitag.com/tools/sql_reserved_words_checker/?word=description www.elsasoft.org |
 |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-05-08 : 14:40:27
|
quote: Originally posted by jezemine also just because a word lights up in SSMS doesn't mean it's reserved.
Isn't that special..another undocumented "feature"Brett8-)EDIT: Oh, and don't use reserved words, unless you have to, then always use brackets..there are some words that will cause syntax to mess up, and other won't..try making a column named "Go"Why would you have to? Because your company may purchase some bonehead 3rd party package...those guys are always so clever...Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-08 : 14:50:00
|
No guarantee what Reserve Words will be added in the next version, and maybe they will clash with your carefuly considered column names anyway ...... we've used CamelCase in the past and not realised that the individual parts of the name actually combined into a regular word Kristen |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-08 : 14:51:14
|
that's PascalCase, not camelCase.  www.elsasoft.org |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-08 : 14:51:32
|
As a general rule, you should avoid having reserved words as database object names. It's not just because of syntax error caused by SQL, but also it makes code more readable and less confusing.For example, how readable is this code?select [select] from( select 1 as [Select] union all select 2 union all select 3) [from]Order by [Select] When you can't avoid it for some reason and when you are unsure about SQL Server's behavior, enclose it inside square brackets.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-08 : 14:57:37
|
"that's PascalCase, not camelCase"Nah, you are mistakenly referring to lowerCamelCase!http://en.wikipedia.org/wiki/CamelCase ... which also X-references PascalCase of course Kristen |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-08 : 16:45:19
|
on my ranch, the camels all keep their heads down low. www.elsasoft.org |
 |
|
|