1: Use SQL to bring the stored procedure
EXEC SP_PKEYS @ Table_name = 'Name'
2: Utilize system table information_schema.key_column_usage
SELECT TABLE_NAME, Column_name from Information_schema.key_column_usage where table_name = 'Name'
3: The following query table structure may have seen:
With syscolumns, sysindexes, sysindexkeys, three tables, can detect primary key select (Case When a.colorder = 1 Then D.Name Else '' end) n 'table name, a.colorder n' field number, a.name N 'Field Name, (Case When ColumnProperty (A.ID, A.NAME,' ISIDENTITY ') = 1 Ten' √'lse '' end) n 'Identifier', (Case When (Select Count (*) from sysobjects WHERE (Select Name from sysindexes where (id = a.id) and (indeed in (select = a.id) and (select colid from syscolumns where )))))))))))))))))> 0 THEN '√' else '' end) n 'primary key', B.Name n 'type', a. Length N 'Treasses', ColumnProperty (A.ID, A.NAME, 'Precision') AS N 'Length', ISNULL (ColumnProperty (A.ID, A.NAME, 'Scale'), 0) AS N 'Digital number', (Case When A.isnullable = 1 Then '√'ELSE' 'end) N' Allow empty ', isnull (E.TEXT,' ') N' Default ', ISNULL (G. [Value ], '') AS N 'Field Description' - Into ## TX
From syscolumns a left a.xtype = B.XUSERTYPEINNER JOIN SYSOBJECTS D on A.ID = D.ID and D.XTYPE = 'u' and d.name <> DTPROPERTIES'LEFT JOIN SYSCOMFAMFAMFAMENTS EON A. CDEFAULT = E.IDLEFT JOIN SYSPROPERTIES GON A.ID = g.id and a.colid = g.smallid ORDER BY Object_name (a.id), A.ColORDER4:
SELECT O.NAME AS Name, C.Name AS Field Name, K.COLID AS Field Serial No. o on i.id = o.idjoin syscolumns c on i.id = c.id and k.colid = c.colidwhere o.xtype = 'urid exists (select 1 from sysobjects where xtype =' pk 'and name = I.Name) Order by .name, k.colid