<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database</title>
	<atom:link href="http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ty</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-56793</link>
		<dc:creator>Ty</dc:creator>
		<pubDate>Mon, 19 Oct 2009 14:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-56793</guid>
		<description>once again your SQL scripts have proven to be incredibly useful.  
Thank you!</description>
		<content:encoded><![CDATA[<p>once again your SQL scripts have proven to be incredibly useful.<br />
Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajnish Awasthi</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-56300</link>
		<dc:creator>Rajnish Awasthi</dc:creator>
		<pubDate>Thu, 01 Oct 2009 05:42:48 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-56300</guid>
		<description>Very nice script, it is really helpful.</description>
		<content:encoded><![CDATA[<p>Very nice script, it is really helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-55780</link>
		<dc:creator>M</dc:creator>
		<pubDate>Thu, 10 Sep 2009 18:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-55780</guid>
		<description>Excellent site.

The queries above (except for Smeet&#039;s) return extra incorrect rows for compound FKs.

I ran a SQL Profiler trace while scripting out a compound FK in Management Studio and here is what I found in the Profiler trace. The result additionally outputs an ID column that displays the correct order in which the PK table columns are referenced.

Cheers

  select tbl.name                  as [Table_Name]     ,
         cstr.name                 as [ForeignKey_Name],
         fk.constraint_column_id   as [ID]             ,
         cfk.name                  as [Name]           ,
         crk.name                  as [ReferencedColumn]
    from sys.tables                as tbl
       inner join sys.foreign_keys as cstr
               on cstr.parent_object_id=tbl.object_id
       inner join sys.foreign_key_columns as fk
               on fk.constraint_object_id=cstr.object_id
       inner join sys.columns as cfk
               on fk.parent_column_id = cfk.column_id
              and fk.parent_object_id = cfk.object_id
       inner join sys.columns as crk
               on fk.referenced_column_id = crk.column_id
              and fk.referenced_object_id = crk.object_id
order by [Table_Name] asc     ,
         [ForeignKey_Name] asc,
         [ID] asc</description>
		<content:encoded><![CDATA[<p>Excellent site.</p>
<p>The queries above (except for Smeet&#8217;s) return extra incorrect rows for compound FKs.</p>
<p>I ran a SQL Profiler trace while scripting out a compound FK in Management Studio and here is what I found in the Profiler trace. The result additionally outputs an ID column that displays the correct order in which the PK table columns are referenced.</p>
<p>Cheers</p>
<p>  select tbl.name                  as [Table_Name]     ,<br />
         cstr.name                 as [ForeignKey_Name],<br />
         fk.constraint_column_id   as [ID]             ,<br />
         cfk.name                  as [Name]           ,<br />
         crk.name                  as [ReferencedColumn]<br />
    from sys.tables                as tbl<br />
       inner join sys.foreign_keys as cstr<br />
               on cstr.parent_object_id=tbl.object_id<br />
       inner join sys.foreign_key_columns as fk<br />
               on fk.constraint_object_id=cstr.object_id<br />
       inner join sys.columns as cfk<br />
               on fk.parent_column_id = cfk.column_id<br />
              and fk.parent_object_id = cfk.object_id<br />
       inner join sys.columns as crk<br />
               on fk.referenced_column_id = crk.column_id<br />
              and fk.referenced_object_id = crk.object_id<br />
order by [Table_Name] asc     ,<br />
         [ForeignKey_Name] asc,<br />
         [ID] asc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kunal Shah</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54785</link>
		<dc:creator>Kunal Shah</dc:creator>
		<pubDate>Wed, 12 Aug 2009 15:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54785</guid>
		<description>Good script !!! saved lot time.</description>
		<content:encoded><![CDATA[<p>Good script !!! saved lot time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marie Magdz</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54246</link>
		<dc:creator>Marie Magdz</dc:creator>
		<pubDate>Thu, 30 Jul 2009 06:11:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54246</guid>
		<description>You guys rock! This has saved me sooo much time. Thanks all</description>
		<content:encoded><![CDATA[<p>You guys rock! This has saved me sooo much time. Thanks all</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ty A.</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54144</link>
		<dc:creator>Ty A.</dc:creator>
		<pubDate>Mon, 27 Jul 2009 18:03:54 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-54144</guid>
		<description>This script is amazing, it saved my life.</description>
		<content:encoded><![CDATA[<p>This script is amazing, it saved my life.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaseem</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-52197</link>
		<dc:creator>Jaseem</dc:creator>
		<pubDate>Fri, 22 May 2009 13:13:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-52197</guid>
		<description>Hi
How to retrieve all columns of the given table and its foreign key table.
Regards
Jaseem, A.</description>
		<content:encoded><![CDATA[<p>Hi<br />
How to retrieve all columns of the given table and its foreign key table.<br />
Regards<br />
Jaseem, A.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dakshina Murthy</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51315</link>
		<dc:creator>Dakshina Murthy</dc:creator>
		<pubDate>Mon, 27 Apr 2009 10:20:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51315</guid>
		<description>Hi,

It was great, it helped me in finding the duplicate FK for the same set of tables for the same set of fields.

With Regards
Dakshina Murthy</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>It was great, it helped me in finding the duplicate FK for the same set of tables for the same set of fields.</p>
<p>With Regards<br />
Dakshina Murthy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo Veliz</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51252</link>
		<dc:creator>Pablo Veliz</dc:creator>
		<pubDate>Thu, 23 Apr 2009 20:27:38 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51252</guid>
		<description>excelente, gracias por publicarlo.</description>
		<content:encoded><![CDATA[<p>excelente, gracias por publicarlo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wannabag</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51215</link>
		<dc:creator>Wannabag</dc:creator>
		<pubDate>Wed, 22 Apr 2009 13:42:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-51215</guid>
		<description>Excellent script thank you</description>
		<content:encoded><![CDATA[<p>Excellent script thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dinci</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-50488</link>
		<dc:creator>Dinci</dc:creator>
		<pubDate>Sat, 04 Apr 2009 19:26:14 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-50488</guid>
		<description>Excellent script that got me going in the right direction. Thank you so much.</description>
		<content:encoded><![CDATA[<p>Excellent script that got me going in the right direction. Thank you so much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sanjay</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-49267</link>
		<dc:creator>Sanjay</dc:creator>
		<pubDate>Tue, 17 Mar 2009 07:02:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-49267</guid>
		<description>I want to retrieve only limited data from database like limit is keyword in mysql which retrieve limited data according to our arguments. Like I want to load only 10 records from the database at first display in page. but I don’t want to using top. Because its create problem of paging. So please give me alternate solution for that’d have use row index but in that row index I have to write inner query and my data base I s to heavy.</description>
		<content:encoded><![CDATA[<p>I want to retrieve only limited data from database like limit is keyword in mysql which retrieve limited data according to our arguments. Like I want to load only 10 records from the database at first display in page. but I don’t want to using top. Because its create problem of paging. So please give me alternate solution for that’d have use row index but in that row index I have to write inner query and my data base I s to heavy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karan Kang</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-48411</link>
		<dc:creator>Karan Kang</dc:creator>
		<pubDate>Sun, 08 Mar 2009 10:11:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-48411</guid>
		<description>Nice ..the script really helped me..!
Thanks..!</description>
		<content:encoded><![CDATA[<p>Nice ..the script really helped me..!<br />
Thanks..!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Smeet</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-45221</link>
		<dc:creator>Smeet</dc:creator>
		<pubDate>Wed, 31 Dec 2008 08:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-45221</guid>
		<description>MAKE IT MORE SHORT N SIMPLE
 Will work on both 2000 and 2005
===========================

select object_name(constid) FKey_Name, object_name(fkeyid) Child_Table, c1.name FKey_Col, 
object_name(rkeyid) Parent_Table, c2.name Ref_KeyCol
from sysforeignkeys s
inner join syscolumns c1
on ( s.fkeyid = c1.id
and s.fkey = c1.colid  )
inner join syscolumns c2
on ( s.rkeyid = c2.id
and s.rkey = c2.colid  )</description>
		<content:encoded><![CDATA[<p>MAKE IT MORE SHORT N SIMPLE<br />
 Will work on both 2000 and 2005<br />
===========================</p>
<p>select object_name(constid) FKey_Name, object_name(fkeyid) Child_Table, c1.name FKey_Col,<br />
object_name(rkeyid) Parent_Table, c2.name Ref_KeyCol<br />
from sysforeignkeys s<br />
inner join syscolumns c1<br />
on ( s.fkeyid = c1.id<br />
and s.fkey = c1.colid  )<br />
inner join syscolumns c2<br />
on ( s.rkeyid = c2.id<br />
and s.rkey = c2.colid  )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dalbir</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-44243</link>
		<dc:creator>Dalbir</dc:creator>
		<pubDate>Mon, 17 Nov 2008 07:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-44243</guid>
		<description>Thanks, Great scripting</description>
		<content:encoded><![CDATA[<p>Thanks, Great scripting</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karim</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43950</link>
		<dc:creator>Karim</dc:creator>
		<pubDate>Tue, 28 Oct 2008 17:24:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43950</guid>
		<description>Hi,
here&#039;s another version (mine :-; ) to extract foreign keys.

Replace &#039;TABLE_NAME&#039; with yours ... !

Regards
Karim Laurent


select OBJECT_NAME(FKEYS.PARENT_OBJECT_ID) source ,PKCOLUMN_NAME= convert(sysname,col1.name), OBJECT_NAME(FKEYS.referenced_object_id) destination, FKCOLUMN_NAME       = convert(sysname,COL2.name)  

from 

sys.columns COL1,

sys.columns COL2,

sys.foreign_keys FKEYS

inner join sys.foreign_key_columns KEY_COLUMN on (KEY_COLUMN.constraint_object_id = FKEYS.object_id)

where 

COL1.object_id = FKEYS.referenced_object_id 

AND COL2.object_id = FKEYS.parent_object_id 

AND COL1.column_id = KEY_COLUMN.referenced_column_id 

AND COL2.column_id = KEY_COLUMN.parent_column_id

AND OBJECT_NAME(FKEYS.PARENT_OBJECT_ID)=&#039;TABLE_NAME&#039;</description>
		<content:encoded><![CDATA[<p>Hi,<br />
here&#8217;s another version (mine :-; ) to extract foreign keys.</p>
<p>Replace &#8216;TABLE_NAME&#8217; with yours &#8230; !</p>
<p>Regards<br />
Karim Laurent</p>
<p>select OBJECT_NAME(FKEYS.PARENT_OBJECT_ID) source ,PKCOLUMN_NAME= convert(sysname,col1.name), OBJECT_NAME(FKEYS.referenced_object_id) destination, FKCOLUMN_NAME       = convert(sysname,COL2.name)  </p>
<p>from </p>
<p>sys.columns COL1,</p>
<p>sys.columns COL2,</p>
<p>sys.foreign_keys FKEYS</p>
<p>inner join sys.foreign_key_columns KEY_COLUMN on (KEY_COLUMN.constraint_object_id = FKEYS.object_id)</p>
<p>where </p>
<p>COL1.object_id = FKEYS.referenced_object_id </p>
<p>AND COL2.object_id = FKEYS.parent_object_id </p>
<p>AND COL1.column_id = KEY_COLUMN.referenced_column_id </p>
<p>AND COL2.column_id = KEY_COLUMN.parent_column_id</p>
<p>AND OBJECT_NAME(FKEYS.PARENT_OBJECT_ID)=&#8217;TABLE_NAME&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43682</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Tue, 14 Oct 2008 02:39:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43682</guid>
		<description>Fantastic script, thank you so much!</description>
		<content:encoded><![CDATA[<p>Fantastic script, thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43495</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Sat, 04 Oct 2008 00:47:35 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43495</guid>
		<description>Hello, 

This one is simpler, just gives you table_name and which type of key information and key name.

select OBJECT_NAME(PARENT_OBJ) TABLE_NAME, CASE WHEN XTYPE =&#039;F&#039; THEN &#039;FORIEGN KEY&#039; ELSE &#039;PRIMARY KEY&#039; END KEY_TYPE , NAME KEY_NAME
from sysobjects where Xtype  in (&#039;F&#039; , &#039;pK&#039;) ORDER BY XTYPE DESC 

I am using only sysobjects table to get this information.


Hope this helps.
Imran.</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>This one is simpler, just gives you table_name and which type of key information and key name.</p>
<p>select OBJECT_NAME(PARENT_OBJ) TABLE_NAME, CASE WHEN XTYPE =&#8217;F&#8217; THEN &#8216;FORIEGN KEY&#8217; ELSE &#8216;PRIMARY KEY&#8217; END KEY_TYPE , NAME KEY_NAME<br />
from sysobjects where Xtype  in (&#8216;F&#8217; , &#8216;pK&#8217;) ORDER BY XTYPE DESC </p>
<p>I am using only sysobjects table to get this information.</p>
<p>Hope this helps.<br />
Imran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aniket Tamhane</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43481</link>
		<dc:creator>Aniket Tamhane</dc:creator>
		<pubDate>Fri, 03 Oct 2008 14:44:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-43481</guid>
		<description>Nice one... It helped me to a lot during SQL Server Replication Setup</description>
		<content:encoded><![CDATA[<p>Nice one&#8230; It helped me to a lot during SQL Server Replication Setup</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cowboy</title>
		<link>http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-42407</link>
		<dc:creator>Cowboy</dc:creator>
		<pubDate>Thu, 04 Sep 2008 21:10:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2007/01/09/query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/#comment-42407</guid>
		<description>PINAL, I have a somewhat related problem that i was wondering if you had a solution for

There are 4 tables with relationships to each other. ConferenceRoom, ConferenceRoomCapacity, TeleTrackPhone, and RPSLocation

The table ConferenceRoom stores attributes pertaining to conference rooms.

The table ConferenceRoomCapacity stores attributes pertaining to the maximum capacity of the conference room.

The table TeleTrackPhone contains different phone numbers. It stores ConferenceRoomID and RPSLocationID as  FKs.

The table RPSLocation stoes info about different locations, city, state, etc.

The TeleTrackPhone table allows duplicate values for the ConferenceRoomID because a conference room can have more than one phone number.

This is the query that I run.

SELECT DISTINCT A.ConferenceRoomID, A.ConferenceRoomName, C.City, C.State
FROM ConferenceRoom As A, TeleTrackPhone As B, RPSLocation As C, ConferenceRoomCapacity As D
WHERE A.ConferenceRoomID = B.ConferenceRoomID
AND B.RPSLocationID = C.RPSLocationID
AND A.ConferenceRoomID = D.ConferenceRoomID

My problem is that it returns duplicates if the conference room has multiple phone numbers and i only want the query to return a list of conference rooms.</description>
		<content:encoded><![CDATA[<p>PINAL, I have a somewhat related problem that i was wondering if you had a solution for</p>
<p>There are 4 tables with relationships to each other. ConferenceRoom, ConferenceRoomCapacity, TeleTrackPhone, and RPSLocation</p>
<p>The table ConferenceRoom stores attributes pertaining to conference rooms.</p>
<p>The table ConferenceRoomCapacity stores attributes pertaining to the maximum capacity of the conference room.</p>
<p>The table TeleTrackPhone contains different phone numbers. It stores ConferenceRoomID and RPSLocationID as  FKs.</p>
<p>The table RPSLocation stoes info about different locations, city, state, etc.</p>
<p>The TeleTrackPhone table allows duplicate values for the ConferenceRoomID because a conference room can have more than one phone number.</p>
<p>This is the query that I run.</p>
<p>SELECT DISTINCT A.ConferenceRoomID, A.ConferenceRoomName, C.City, C.State<br />
FROM ConferenceRoom As A, TeleTrackPhone As B, RPSLocation As C, ConferenceRoomCapacity As D<br />
WHERE A.ConferenceRoomID = B.ConferenceRoomID<br />
AND B.RPSLocationID = C.RPSLocationID<br />
AND A.ConferenceRoomID = D.ConferenceRoomID</p>
<p>My problem is that it returns duplicates if the conference room has multiple phone numbers and i only want the query to return a list of conference rooms.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
