Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2005
    Posts
    55

    Unanswered: using 'user_id' as field name?

    hey everyone,

    as the title suggests, and being that user_id is an SQL Server keyword, can I use 'user_id' as field name in my 'users' table, without SQL Server getting confused between the field name and the keyword?

    Thank you all in advance,
    Justin

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Could you? Maybe.

    Should You? No.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Aug 2005
    Posts
    55
    Quote Originally Posted by loquin
    Could you? Maybe.

    Should You? No.
    is there any other table name & field prefix that you suggest as an alternative, as I cannot use clients, as I have a table already called clients

    Cheers

  4. #4
    Join Date
    Feb 2007
    Location
    Chennai, TN
    Posts
    68
    Hi,
    We can create the user_id as column name for the table you have created (Users). We have already worked on this. we have used object_id in one of our table as a column name and we did not face any problem while querying a table based on object_id field of that table

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by freefall
    ... being that user_id is an SQL Server keyword
    no it isn't
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Is does come up nice and pink in SSMS (by default anyway). I assumed that indicated a reserverd word - is it just a colourful word?

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002

  8. #8
    Join Date
    Nov 2006
    Location
    Quebec
    Posts
    172
    you can use [user_id] instead of user_id but using reserved word as a column name is a bad thing.
    Less is more.
    How long is now?
    http://www.lesouterrain.com

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    user_id is not a reserved word
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  10. #10
    Join Date
    Dec 2007
    Posts
    7
    user_id ,, is not a reserved word in SQL server
    but if it !!!
    you can use users_id !!
    its good

  11. #11
    Join Date
    Aug 2005
    Posts
    55
    Quote Originally Posted by pootle flump
    Is does come up nice and pink in SSMS (by default anyway). I assumed that indicated a reserverd word - is it just a colourful word?
    Which is why I assumed it as a keyword or reserved word.

    but since it is not, I wonder why SSMS highlights it as pink...very misleading...

    thanks for the links on the reserved words list, confirmed it.

    Cheers all,

    Justin

  12. #12
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    Quote Originally Posted by pootle flump
    Is does come up nice and pink in SSMS (by default anyway). I assumed that indicated a reserverd word - is it just a colourful word?
    it's colorized only because of the user_id() function.

    http://msdn2.microsoft.com/en-us/library/ms181466.aspx

  13. #13
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Ah! Of course! Thanks for explaining the colourfication

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •