﻿<?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 / Article Discussions by Author / Discuss content posted by Sandeep Saretha  / SQL 2005 - List Primary Key Columns / 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>Sat, 25 May 2013 07:10:58 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>[quote][b]belowery (6/29/2012)[/b][hr]I talked to my DBA and he said these are automatically updated.  So it must be a permissions issue that is stopping you from seeing anything.[/quote]Thank you.  At least I know.  I suppose I can get along without them.  I have thus far.  ;-)Dana</description><pubDate>Fri, 29 Jun 2012 13:01:26 GMT</pubDate><dc:creator>danaanderson</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>I talked to my DBA and he said these are automatically updated.  So it must be a permissions issue that is stopping you from seeing anything.</description><pubDate>Fri, 29 Jun 2012 12:41:40 GMT</pubDate><dc:creator>belowery</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>I have plenty of tables, I've been using it for a while.  And there are indexes.  And stored procedures and functions.  But still, the script returns an empty results set.  It seems that something must be done to populate these views.  I'm no DBA either, except by necessity.  The database is on my shared hosting, so maybe there are some constraints there.  I know there are other things that I do not have access to.  For example, there have been scripts that access certain system stored procedures and are meant to help with optimizing and finding where things could be sped up. They don't work, either.  But in those cases I get an error message that states that I don't have privileges to those procedures.  This doesn't complain, it just returns and empty set.  *shrug*Dana</description><pubDate>Fri, 29 Jun 2012 12:28:44 GMT</pubDate><dc:creator>danaanderson</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>It could be either your table does not have an index set up, or the database doesn't have any tables that have indexes.  You need to be connected to the database where the table exists for either of these to work.I don't think anything needs to be done for this to work, but then I'm not a DBA.</description><pubDate>Fri, 29 Jun 2012 10:11:45 GMT</pubDate><dc:creator>belowery</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>I ran this and got an empty results set.  Is there something that needs to be done to populate these schema views?  This is a totally new subject for me.  I was under the impression that these views would be already defined in the system and can just be queried as in this article.Dana</description><pubDate>Fri, 29 Jun 2012 10:03:27 GMT</pubDate><dc:creator>danaanderson</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>Nice idea. I tested it on 2000, 2005, and 2008. It works well on all of them.</description><pubDate>Fri, 29 Jun 2012 08:36:28 GMT</pubDate><dc:creator>Dave Vroman</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>Here is a query to find all the indexes on a table.select r.[name] as table_name, i.[name] as index_name, c.[name] as column_nameFROM sys.index_columns l	inner join sys.tables r on		l.object_id = r.object_id	inner join sys.indexes i on		l.object_id = i.object_id		and l.index_id = i.index_id	inner join sys.columns c on		l.object_id = c.object_id		and l.column_id = c.column_idwhere r.[name] = '[i]table_name_here'[/i]order by r.[name], l.index_id, l.key_ordinal</description><pubDate>Fri, 29 Jun 2012 08:25:44 GMT</pubDate><dc:creator>belowery</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>I like the ides of this, I would add ordering the columns as they are defined in the key.  And for the programmers in my area I would add a statement in the where clause so they only got the table they need instead of every table on the database.SELECT p.TABLE_NAME, c.CONSTRAINT_NAME, c.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS p 	inner join INFORMATION_SCHEMA.KEY_COLUMN_USAGE c on		c.TABLE_NAME = p.TABLE_NAME		AND c.CONSTRAINT_NAME = p.CONSTRAINT_NAMEWHERE CONSTRAINT_TYPE = 'PRIMARY KEY'	AND p.TABLE_NAME = 'name_here'ORDER by c.TABLE_NAME, c.ordinal_position</description><pubDate>Fri, 29 Jun 2012 07:08:24 GMT</pubDate><dc:creator>belowery</dc:creator></item><item><title>RE: SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>Nice idea and this is a nice foundation script.</description><pubDate>Mon, 04 Jan 2010 17:31:55 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>SQL 2005 - List Primary Key Columns</title><link>http://www.sqlservercentral.com/Forums/Topic473303-1187-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Normalization/62620/"&gt;SQL 2005 - List Primary Key Columns&lt;/A&gt;[/B]</description><pubDate>Sun, 23 Mar 2008 08:25:33 GMT</pubDate><dc:creator>Sandeep Saretha</dc:creator></item></channel></rss>