Faster Version of sp_fkeys for SQL Server 2005
DiggBlinkRedditDeliciousTechnorati
article by keyvez
If you've ever wanted to find the foreign keys that depend on a particular table or a primary key that acts as a foreign key in other tables, you could use the sp_fkeys system procedure provided in SQL Server.
However, since SQL 2005 sp_fkeys has become really slow. Depending on the size of the database it could enormously add to the execution time for a particular table.
Here is a modified stored procedure which matches the execution speed of the 2000 version of sp_fkeys on 2005.
The resultset and returnvalues are exactly like the sp_fkeys stored procedure and I admit that the only change I made was added a new if block to the actual code.
Download it at: http://www2.keyvez.com:82/?q=node/12