sqlserver一键生成表结构表格

1、首先获取所有的表

SELECT name, id From sysobjects WHERE xtype = 'u' ORDER BY name ASC

 

2、根据表名查询字段信息

 

select syscolumns.name, syscolumns.length, systypes.name   as   typename, sys.extended_properties.[value] AS tname,syscolumns.isnullable  from   syscolumns join systypes   on   
syscolumns.xtype=systypes.xtype and systypes.name <> 'sysname' LEFT OUTER JOIN sys.extended_properties ON
( sys.extended_properties.minor_id = syscolumns.colid AND sys.extended_properties.major_id = syscolumns.id)

where syscolumns.id in (select id from sysobjects where name= 'T_SAFETY_LIABILITY_TRADE')

 

 

 

 

posted on 2024-05-14 07:52  五官一体即忢  阅读(85)  评论(0编辑  收藏  举报

导航