0
問題在標題:)。我需要知道是否有可能。從視圖獲取外鍵列元數據
這裏是如何做到這一點的表
SELECT
OBJECT_NAME(f.parent_object_id) as tbl,
OBJECT_NAME(fc.referenced_object_id) as refTable,
COL_NAME(f.parent_object_id, fc.parent_column_id) as foreignKeyColumnName
FROM sys.foreign_keys f
INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id
WHERE f.parent_object_id = OBJECT_ID('dbo.TableName')
感謝馬克,也許有可能得到它從關聯表通過視圖。 – Danil 2011-03-10 16:37:47
@Danil:當然 - 你只需要知道視圖依賴的表格,然後使用你發佈的代碼。 – 2011-03-10 17:10:16