Microsoft SQL Server: How to Find the Foreign Keys in a Database June 21st, 2009
| A foreign key is a column or columns that are used to enforce a link between data in two tables. While SQL Server gives you no quick and easy way to view all foreign keys in a database, this quick query will give you that information. It comes in handy when trying to troubleshoot Foreign Key Constraint errors.
1. Open a New Query on the desired database. 2. Copy, paste, and execute the following: FROM FROM ON e.TABLE_NAME = d.TABLE_NAME ORDER BY a.CONSTRAINT_NAME You can now easily see all foreign keys in that database. courtesy http://www.tech-recipes.com/rx/3194/microsoft-sql-server-how-to-find-the-foreign-keys-in-a-database/ |
This entry was posted on Sunday, June 21st, 2009 at 12:08 pm and is filed under databases, sql server. You can follow any responses to this entry through the RSS 2.0 feed.You can leave a response, or trackback from your own site.
