This procedure will give the list of columns included in the primary key for a given table of given database on given server.
For. e.g.
Get_PrimaryKey 'vrs-118','Demo_StDB','IMAGEREPOSITORY'
2001-08-22
729 reads
This procedure will give the list of columns included in the primary key for a given table of given database on given server.
For. e.g.
Get_PrimaryKey 'vrs-118','Demo_StDB','IMAGEREPOSITORY'
CREATE PROCEDURE Get_PrimaryKey @ServerName varchar(50), @CatalogName varchar(50), @TableName varchar(50) AS EXEC sp_serveroption @ServerName, 'data access', 'true' select COLUMN_NAME = COLUMN_NAME from master.dbo.SYSREMOTE_PRIMARY_KEYS ( @ServerName,@CatalogName, N'dbo',@TableName ) EXEC sp_serveroption @ServerName, 'data access', 'false' GO