--获取表的名称及用表中第一列的注释作表的说明
select 'delete from ',Name2 ,'--',RANK()OVER (ORDER BY Name2 DESC) as 序号,字段说明 from
(
select bb.name as Name2,cc.* from (
select min(minor_id) as minor_id,id from (
SELECT g.minor_id minor_id,a.Name as Name ,a.Length as Len,b.Name as [Type],ISNULL(g.[value], '') AS 字段说明 ,a.id
--select *
FROM syscolumns as a
left join systypes b on a.xusertype=b.xusertype INNER JOIN dbo.sysobjects d ON a.id = d.id AND d.xtype = 'U'
AND d.status >= 0 LEFT OUTER JOIN dbo.syscomments e ON a.cdefault = e.id LEFT
OUTER JOIN sys.extended_properties g ON a.id = g.major_id AND a.colid = g.minor_id AND
g.name = 'MS_Description' LEFT OUTER JOIN sys.extended_properties f ON d.id = f.major_id AND f.minor_id = 0
AND f.name = 'MS_Description'where b.Name <> 'sysname' --group by a.id
--AND a.id=object_id('dbo.T_CarInfo')
) gg group by id
)as cc
,
(
SELECT name,id FROM sysobjects where xtype= 'u ') as bb
where bb.id=cc.id
) as dA LEFT JOIN
(
SELECT g.minor_id minor_id,a.Name as Name ,a.Length as Len,b.Name as [Type],ISNULL(g.[value], '') AS 字段说明, a.id as idd,CRDATE
--select *
FROM syscolumns as a
left join systypes b on a.xusertype=b.xusertype INNER JOIN dbo.sysobjects d ON a.id = d.id AND d.xtype = 'U'
AND d.status >= 0 LEFT OUTER JOIN dbo.syscomments e ON a.cdefault = e.id LEFT
OUTER JOIN sys.extended_properties g ON a.id = g.major_id AND a.colid = g.minor_id AND
g.name = 'MS_Description' LEFT OUTER JOIN sys.extended_properties f ON d.id = f.major_id AND f.minor_id = 0
AND f.name = 'MS_Description'where b.Name <> 'sysname'
)
as dB ON dA.minor_id=dB.minor_id and id=idd
执行以上SQL语句,就可生成整个数据库的delete语句了