Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Posts
    8

    Unanswered: Return Table's ID

    Has anyone been able to use SQL to find a tables associated ID number?

    For example, when I select * from syscolumns I get a list of columns in the DB and an ID number that refers to the table it belongs to. I would like a way to query the DB by the table name and return that ID.

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    select id from sysobjects where name = @tblname
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd use Object_Id(), something like:
    Code:
    SELECT Object_Id('sysobjects')
    for something like that.

    -PatP

  4. #4
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    yeah ... that would be a better option .... i completely forgot about it
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  5. #5
    Join Date
    Jun 2004
    Posts
    8
    Awesome, Thanks!

Posting Permissions

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