sqlserver根据表名获取表的所有列及属性.docxVIP

  • 37
  • 0
  • 约1.06千字
  • 约 2页
  • 2021-11-21 发布于山东
  • 举报

sqlserver根据表名获取表的所有列及属性.docx

Sql Server 依据表名获得表的全部列及属性 实例一: select a.name columnname,c.name as typename,case when a.is_nullable =0 then Not Null else Null end as nullable,a.* from sys.columns a , sys.objects b, sys.types c where a.object_id= b.object_id and b.name= 表名 实例二: select c.name as [ 字段名 ],t.name as [ 字段种类 ] ,convert(bit,c.IsNullable) as [ 能否为空 ] ,convert(bit,case when exists(select 1 from sysobjects where xtype=PK and parent_obj=c.id and name in ( select name from sysindexes where indid in( select indid from sysindexkeys where id = c.id and colid=c.colid))) then 1 else 0 end) as [ 能否主键 ] ,convert(bit,COLUMNPROP

文档评论(0)

1亿VIP精品文档

相关文档