September 26, 2007 at 9:34 pm
Comments posted to this topic are about the item To get Table and column name for Primary Keys.
Thanks
Mohit Nayyar
http://mohitnayyar.blogspot.com/
"If I am destined to fail, then I do have a purpose in my life, To fail my destiny"
November 13, 2010 at 7:59 pm
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
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy