1.没看懂 但先收藏着 以后认知
select C.name,T.name,primarykey = case (select is_primary_key
from sys.indexes IDX where IDX.object_id=IDXC.object_id and c.column_id=IDXC.column_id )
when 1 then 1
else 0
end from sys.columns C --有关列信息表
INNER JOINsys.objects O --表的信息表
on O.object_id=C.object_idINNER JOIN sys.types T --数据类型
on C.system_type_id=T.system_type_idleft JOIN sys.index_columns IDXC--主键信息onC.object_id=IDXC.object_idwhere O.name=N'表名'
2.
select * from information_schema.columns where table_name= 'test '