select statement that returns the column names and keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tgru

    select statement that returns the column names and keys


    Does anyone know a select statement that would return the column names
    and keys and indexes of a table?

    Thanks,

    TGru

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Simon Hayes

    #2
    Re: select statement that returns the column names and keys

    tgru <tgru@devdex.co m> wrote in message news:<4046be72$ 0$194$75868355@ news.frii.net>. ..[color=blue]
    > Does anyone know a select statement that would return the column names
    > and keys and indexes of a table?
    >
    > Thanks,
    >
    > TGru
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]

    Does sp_help give you the information you need?

    exec sp_help TableName

    Simon

    Comment

    • Mystery Man

      #3
      Re: select statement that returns the column names and keys

      tgru <tgru@devdex.co m> wrote in message news:<4046be72$ 0$194$75868355@ news.frii.net>. ..[color=blue]
      > Does anyone know a select statement that would return the column names
      > and keys and indexes of a table?
      >
      > Thanks,
      >
      > TGru
      >
      > *** Sent via Developersdex http://www.developersdex.com ***
      > Don't just participate in USENET...get rewarded for it![/color]

      Try the following

      select * from information_sch ema.columns
      select * from information_sch ema.key_column_ usage

      If that doesn't have the level of detail that you require, try

      select * from syscolumns
      select * from sysconstraints

      Comment

      • tim groulx

        #4
        Re: select statement that returns the column names and keys

        Thanks, these worked perfectly..

        select * from information_sch ema.columns
        select * from information_sch ema.key_column_ usage




        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        Working...