sqlserver 2008 怎么把表结构导出到excel中

zhutuzi1987 2013-02-18 09:03:22
因为要写表明细,每个都写的话需要好久,所以想知道有没有能直接导出来的
...全文
575 1 点赞 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhutuzi1987 2013-02-18
解决了,用下面语句,把表名改一下,复制到excel里面就可以了 Declare @tableName varchar(50) set @tableName='BMG602' SELECT (case when a.colorder=1 then d.name else '' end) as 表名, a.name as 字段名, isnull(g.[value],'') as 字段说明, b.name as 类型, COLUMNPROPERTY(a.id,a.name,'PRECISION') as 长度, isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0)as 小数位数, (case when(SELECT count(*) FROM sysobjects WHERE(name in (SELECT name FROM sysindexes ss WHERE (ss.id=a.id) AND(indid in (SELECT indid FROM sysindexkeys WHERE(id=a.id) AND(colid in (SELECT colid FROM syscolumns WHERE(id=a.id) AND(name=a.name))))))) AND (xtype='PK'))>0 then'是' else '' end) as 是否主键, (case when a.isnullable=1 then '' else '是' end) as 是否必填, isnull(e.text,'') as 默认值 FROM syscolumns a left join systypes b on a.xtype=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 sys.extended_properties g on a.id=g.major_id AND a.colid=g.minor_id --where d.name like '%'+@tableName+'%' where d.name = @tableName order by d.name,a.colorder
  • 打赏
  • 举报
回复
相关推荐
发帖
Oracle 高级技术
加入

3439

社区成员

Oracle 高级技术相关讨论专区
申请成为版主
帖子事件
创建了帖子
2013-02-18 09:03
社区公告
暂无公告