EXECUTE master..sp_MShelpcolumns '?'And returns the following:
Usage: sp_MShelpcolumns @tablename, @flags int = 0 where @flags is a bitmask of: 0x0200 = No DRI (ignore Checks, Primary/Foreign/Unique Keys, etc.) 0x0400 = UDDTs --> Base type 0x80000 = TimestampToBinary (convert timestamp cols to binary(8)) 0x40000000 = No Identity attributeThe call from the SEM looked like this:
sp_MShelpcolumns N'dbo.authors', null, 'id', 1'id' goes into a parameter called @orderby. The source has the following comment for the last parameter - @flags2:
/* Determine if the column is in the primary key */ if (@flags & 0x0200 = 0 and (OBJECTPROPERTY(@objid, N'TableHasPrimaryKey') <> 0)) begin declare @indid int select @indid = indid from dbo.sysindexes i where i.id = @objid and i.status & 0x0800 <> 0 if (@indid is not null) update #sphelpcols set col_flags = col_flags | 0x0004 from #sphelpcols c, dbo.sysindexkeys i where i.id = @objid and i.indid = @indid and i.colid = c.col_idI'd consider calling this proc to retrieve the information that you're looking for to be about a half-step safer than getting it from the system tables directly.