﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Discuss content posted by Mohit Nayyar / Article Discussions by Author  / To get Table and column name for Primary Keys. / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 09:47:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: To get Table and column name for Primary Keys.</title><link>http://www.sqlservercentral.com/Forums/Topic403311-613-1.aspx</link><description>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_ManagementSELECT o.name, c.nameFROM sysindexes ixJOIN sysobjects o ON ix.id = o.idJOIN sysobjects pk ON ix.name = pk.nameAND pk.parent_obj = ix.idAND pk.xtype = 'PK'JOIN sysindexkeys ixk on ix.id = ixk.idAND ix.indid = ixk.indidJOIN syscolumns c ON ixk.id = c.idAND ixk.colid = c.colidWHERE o.name = 'MAIL_MESSAGES'ORDER BY ixk.keynoArt</description><pubDate>Sat, 13 Nov 2010 19:59:36 GMT</pubDate><dc:creator>artvanhecke</dc:creator></item><item><title>To get Table and column name for Primary Keys.</title><link>http://www.sqlservercentral.com/Forums/Topic403311-613-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Miscellaneous/30755/"&gt;To get Table and column name for Primary Keys.&lt;/A&gt;[/B]</description><pubDate>Wed, 26 Sep 2007 21:34:00 GMT</pubDate><dc:creator>Mohit Nayyar</dc:creator></item></channel></rss>