know the key columns

  • Hi,

    How can I get the key columns for a table i.e.

    How can I get the primary key and foriegn keys for a table?

    Please respond as soon as possible, its urgent?

    Thanks in advance,

    Venki.

    Thank You

  • venki (11/13/2008)


    Hi,

    How can I get the key columns for a table i.e.

    How can I get the primary key and foriegn keys for a table?

    Please respond as soon as possible, its urgent?

    Thanks in advance,

    Venki.

    use sp_help , you will get complete information about that table.

    or check in the sysindexes table.

  • venki (11/13/2008)


    Hi,

    How can I get the key columns for a table

    OK. I found the solution.

    Here is the query to get the all the primary key and Foreign key coloumn names:

    select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE

    Where TABLE_NAME=Yourtablenamehere

    Thanks in advance,

    Venki.

    Thank You

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply