Monday, September 30, 2013

T-SQL: List all table foreign keys

SELECT f.name AS ForeignKey,
OBJECT_NAME(f.parent_object_id) AS TableName,
COL_NAME(fc.parent_object_id,
fc.parent_column_id) AS ColumnName,
OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
COL_NAME(fc.referenced_object_id,
fc.referenced_column_id) AS ReferenceColumnName
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id


4 comments:

  1. Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔✔✔ Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @ Packers And Movers Chennai

    ReplyDelete
  2. Mohegan Sun Pocono - Mapyro
    Get 아산 출장마사지 directions, reviews 의왕 출장안마 and 전라남도 출장샵 information for 구리 출장마사지 Mohegan Sun Pocono in Wilkes-Barre, PA. The casino, owned by the Mohegan Tribe, features more 김제 출장마사지 than 1,300 slot machines,

    ReplyDelete