资料库中的一些统计SQL
{ Posted on 星期四, 十一月 19, 2009
by Kaiser.XKw
}
资料库中的Trigger统计
select a.name 'Table', i.name 'Insert Trigger', u.name 'Update Trigger', d.name 'Delete Trigger'
from sysObjects a LEFT OUTER JOIN sysObjects i
ON a.instrig = i.id
LEFT OUTER JOIN sysObjects u
ON a.updtrig = u.id
LEFT OUTER JOIN sysObjects d
ON a.deltrig = d.id
where ((a.deltrig>0 or a.instrig>0 or a.updtrig>0) and a.type != 'TR')
资料库中的columns统计
SELECT DISTINCT LEFT(a.name, 30) AS fieldname, left(c.name,20) AS datatype, a.length AS size, b.name AS tablename
FROM syscolumns a INNER JOIN
systypes c ON a.xtype = c.xusertype INNER JOIN
sysobjects b ON a.id = b.id
WHERE (b.xtype = 'U') AND (b.name <> 'dtproperties')
ORDER BY size desc, tablename, fieldname
select a.name 'Table', i.name 'Insert Trigger', u.name 'Update Trigger', d.name 'Delete Trigger'
from sysObjects a LEFT OUTER JOIN sysObjects i
ON a.instrig = i.id
LEFT OUTER JOIN sysObjects u
ON a.updtrig = u.id
LEFT OUTER JOIN sysObjects d
ON a.deltrig = d.id
where ((a.deltrig>0 or a.instrig>0 or a.updtrig>0) and a.type != 'TR')
资料库中的columns统计
SELECT DISTINCT LEFT(a.name, 30) AS fieldname, left(c.name,20) AS datatype, a.length AS size, b.name AS tablename
FROM syscolumns a INNER JOIN
systypes c ON a.xtype = c.xusertype INNER JOIN
sysobjects b ON a.id = b.id
WHERE (b.xtype = 'U') AND (b.name <> 'dtproperties')
ORDER BY size desc, tablename, fieldname
No Response to "资料库中的一些统计SQL"
发表评论