日期:2014-05-18 浏览次数:20618 次
--导出excel处理 declare @s nvarchar(4000) set @s='bcp "'+ +N'select top 100 percent ' +N' case c.colid when 1 then o.name else N'''' end as 表名,' +N' c.colid as 序号,' +N' c.name as 字段名,' +N' t.name 数据类型,' +N' c.prec as 长度,' +N' p.value as 字段说明,' +N' m.text as 默认值' +N' from '+quotename(@dbname)+N'.dbo.sysobjects o' +N' inner join '+quotename(@dbname)+N'.dbo.syscolumns c on o.id=c.id' +N' inner join '+quotename(@dbname)+N'.dbo.systypes t on c.xusertype=t.xusertype' +N' left join '+quotename(@dbname)+N'.dbo.sysproperties p on c.id=p.id and c.colid = p.smallid' +N' left join '+quotename(@dbname)+N'.dbo.syscomments m on c.cdefault=m.id' +N' where o.xtype in(N''U'') and o.status>=0' +N' order by c.id,c.colid' +N'" queryout "'+@fname +N'" /P"" /w' exec master..xp_cmdshell @s,no_output go