• Sorry for the three year old reply,

    You are right, it is a bit complicated. Your method may not return the columns in the correct order. Might I suggest:

    USE Case_Management

    SELECT o.name, c.name

    FROM sysindexes ix

    JOIN sysobjects o ON ix.id = o.id

    JOIN sysobjects pk ON ix.name = pk.name

    AND pk.parent_obj = ix.id

    AND pk.xtype = 'PK'

    JOIN sysindexkeys ixk on ix.id = ixk.id

    AND ix.indid = ixk.indid

    JOIN syscolumns c ON ixk.id = c.id

    AND ixk.colid = c.colid

    WHERE o.name = 'MAIL_MESSAGES'

    ORDER BY ixk.keyno

    Art