select ColumnName,TypeName from
(SELECT colorder=a.colorder,ColumnName=a.name,TypeName=b.name,
IsIdentity=case
when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1
then '√'
else ''
end,
isPK=case
when exists(SELECT 1 FROM sysobjects where xtype='PK' and name in
(SELECT name FROM sysindexes WHERE indid in
( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid )))
then '√'
else ''
end
FROM syscolumns a
left join
systypes b
on a.xusertype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.xtype='U' and d.name<>'dtproperties'
left join syscomments e
on a.cdefault=e.id
left join sysproperties g
on a.id=g.id and a.colid=g.smallid where d.name='TableName' ) Keyname
where IsIdentity='√'

