Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2006, 11:43 AM
SSV SSV is offline
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Number of “Foreign key” references

Hi All,

How to find total number of “Foreign key” references for a “Primary Key” value. Is there any system stored procedure.

For example “UserId“ is my primary key field. “User102” is the value, suppose If I am using this value in other tables, how to find number of references.

Plz help me on this.

Regards,
SSV.
 
Old March 10th, 2006, 04:28 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

If you have defined the foreign keys, you can make a new diagram, select the table with the primary key, click the Add button and check the 'Add related tables automatically' checkbox. It will build a diagram showing you all of the related tables.

 
Old March 11th, 2006, 12:57 AM
SSV SSV is offline
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply. Actually I am displaying all the (primary key) records in the data grid, if particular value referenced in another table than I want to make that one read-only. So I want to know total number of references, if it is more than zero I can make it read-only . Otherwise I have to maintain”UsedCount” column in each table which I have to update each time.

Is there any procedure/trick that returns NUMBER primary key value references?

SSV

 
Old March 15th, 2006, 09:26 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sysobject Table in database. There are all objects of databases.

Peko






Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
references emmgus XSLT 2 August 4th, 2005 01:20 PM
Please help for references rsjaladi Classic ASP Databases 1 November 27th, 2004 04:04 AM
Adding References mahulda ASP.NET 1.0 and 1.1 Basics 0 May 20th, 2004 11:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.