EasyCFM.COM ColdFusion Forums / Coding Help! / "State" and SQL server reserved words

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: "State" and SQL server reserved words -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

mcsolas
01-06-2005 @ 5:49 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 138
Joined: Sep 2003

Everything in my database is good to go into the SQL conversion except for this 1 field. Now, I mention this word "state" over and over on every page in my site as it is also in my database in nearly all tables.

I see that on some lists that its reserved, some its for the future and some it says dont use. I am using SQL 2000 and we will likely move to sql 2005 eventually.

I am of course, recording state names like "FL", "NJ" .. etc. If I have to change it, what is a common name for that field when people need to keep state in the database.

falconseye
01-07-2005 @ 9:31 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

you using 'state' in one your tables will not cause a problem. i use sql server 2000 as well, and i have several tables with state fields. as long as you keep the integrity in terms of how you store the 'state name' you should be fine. for instance, one place you say CA somewhere else you say California. When you try to update any table, then you will need to say
UPDATE...
...
WHERE State = 'CA' OR State = 'California'

hope it helps

falconseye
01-07-2005 @ 9:35 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

just caught something and thought i should let you know.
as for now, state is not a reserved keyword according to the SQL-92 standard. In addition it's not among ODBC Reserved Keywords. however it does say:

Future Keywords
The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers. and STATE is one of them.
Oncee again 'could be ...'
If you are so keen about it,  you may consider using something like
State_Name



falconseye
01-07-2005 @ 9:36 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

don't i like posting ?
check out this link
http://www.yukonxml.com/Reference/default.aspx?t=Keywords

mcsolas
01-07-2005 @ 10:32 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 138
Joined: Sep 2003

You like posting.. maybe you should check out the edit button. Smile  Thanks for that last link, I hadn't had luck finding the sql 2005 list, just numerous other lists kept coming up and each one was a little different. Since 2005 is my 'future' specs here, thats the answer I needed.

State isn't on 2005's list! So many different lists and I wasn't sure which standard I wanted to comply to.

This message was edited by mcsolas on 1-7-05 @ 10:33 AM

VelvettFogg
01-07-2005 @ 10:41 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 384
Joined: Dec 2004

If you are at all concerned about possibly using a reserved word .. dont use it.

Also .. if you make it a habbit to be descriptive about your variable and/or field names, you'll never (almost never) have to worry about reserved words.

I'd never use state, but use stateName ... zip is zipCode ... etc.  the use of two words just about assures me that I'll not accidently use a reserve word.  Falcon suggested state_name, and wile that is just fine, I find that the underscore is harder for me to type quickly, so I use cammelBackNotation in stead.

Luck Smile

mcsolas
01-07-2005 @ 11:44 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 138
Joined: Sep 2003

Yes you are right. However, it seems that I am not using a reserved word .. so I am just going to do less work here. I have my hands full with this one. Thanks for the advice.

Also curious why you prefer to lowercase the first word .. I guess thats camelBackCase. I have the whole thing in CamelCase and it looks very presentable. I now have page names in such a manner and .. well form fields that get automatically written through DW MX 04 also look nice right off the bat. Maybe having to go in and add an occasional space, but its quite fast with that casing prepared.

VelvettFogg
01-07-2005 @ 11:53 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 384
Joined: Dec 2004

I use lowe case on the first word because that's how I was taught Smile

/shrug

falconseye
01-07-2005 @ 12:09 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

it's a generic Java variable definition. almost everybody uses
varName instead of VarName or Var_Name

VelvettFogg
01-07-2005 @ 12:21 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 384
Joined: Dec 2004

camelBackNotation pre-dates Java by many many years.

PAGE: 1 2

Website Designed and Developed by Pablo Varando.