Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Location
    FRANCE (Paris)
    Posts
    23

    Question Unanswered: Queries with system's tables

    Hi,

    I want to make an inventory of (for a dedicated database):

    - The primary keys declared for each table
    - The indexes created for each table.

    Have you some example of queries,
    Thanks a lot,

    Mickael

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    For the indexes, it's easy
    Code:
    SELECT object_name(id), name, indid 
    FROM sysindexes
    For the primary keys, a little bit more complex if your're not filling up syskeys. In a physical point of view, a primary key is defined by (a) unique index using (a) not-nullable value(s)

    BUT, if you're always using the CREATE TABLE ... ( ...COLNAME TYPE PRIMARY KEY, ... syntax, you can plan of the creation of the clustered index and find them using
    Code:
    SELECT object_name(id), name, indid 
    FROM sysindexes 
    WHERE indid=1
    Last edited by fadace; 12-03-03 at 07:00.

  3. #3
    Join Date
    Dec 2003
    Location
    FRANCE (Paris)
    Posts
    23
    Thanks for your reply fadace

Posting Permissions

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