Use below Query to find out the Primary key column from the diffrent table.
SELECT
TC.TABLE_NAME,
KCU.COLUMN_NAME
FROM
INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU
ON TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME
WHERE
TC.CONSTRAINT_TYPE = 'PRIMARY KEY'
Posted by - SUHAS R. KUDEKAR (MCTS - Microsoft Business Intelligence)
Learning Office 2010 + SharePoint 2010 + SQL Server 2008 R2
No comments:
Post a Comment