Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 27th, 2008, 02:38 AM
jomet
Guest
 
Posts: n/a
Default list foreign keys in sql 2000

Hi,

i want to get foreign key details for some validation

foreign key name | owner column | Referred Table | Referred column

of a specified table

how can i do it?
please help me
thanks
:)

jomet.
---------------------------------------------
Once you start a working on something,
dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
  #2 (permalink)  
Old May 1st, 2008, 03:54 PM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I believe the following is what you're looking for:

SELECT OBJECT_NAME(constid), target_table.name AS target_table, target_column.name AS target_column,
    source_table.name AS source_table, source_column.name AS source_column
FROM sysforeignkeys fk
INNER JOIN sysobjects target_table ON fk.fkeyid = target_table.id
INNER JOIN syscolumns target_column ON fk.fkeyid = target_column.id AND fk.fkey = target_column.colid
INNER JOIN sysobjects source_table ON fk.rkeyid = source_table.id
INNER JOIN syscolumns source_column ON fk.rkeyid = source_column.id AND fk.rkey = source_column.colid
ORDER BY OBJECT_NAME(constid), target_table.name

Good luck.

Mark
Reply With Quote
  #3 (permalink)  
Old May 1st, 2008, 11:15 PM
jomet
Guest
 
Posts: n/a
Default

Thanks for your solution.


jomet.
`````````````````````````````````````````````````` ``````````````````````
Once you start a working on something, dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Design: Foreign Key to Multiple Primary Keys? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 10 May 8th, 2008 04:14 PM
list foreign keys jomet Oracle 2 March 28th, 2008 04:17 AM
Copying Databases & Foreign Keys donevco Access 5 February 20th, 2007 08:31 AM
inserting records with foreign and primary keys tdaustin Classic ASP Basics 0 October 4th, 2005 12:49 AM
transfering identites as foreign keys santaji SQL Server DTS 1 September 23rd, 2003 09:28 AM



All times are GMT -4. The time now is 06:23 PM.


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