常用SQL SCRIPT-2
代码
--The following stored procedure lists the stored procedures which contains indicated string.
declare @StringToSearch varchar(100)
SET @StringToSearch = '%tblSubscriptionCount%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @stringtosearch
ORDER BY SO.Name
declare @StringToSearch varchar(100)
SET @StringToSearch = '%tblSubscriptionCount%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @stringtosearch
ORDER BY SO.Name
set statistics profile on
set statistics io on
set statistics time on
go
--to do
go
set statistics profile off
set statistics io off
set statistics time off
set statistics io on
set statistics time on
go
--to do
go
set statistics profile off
set statistics io off
set statistics time off
查询数据表的存储空间使用情况
create table #t(name varchar(255), rows bigint, reserved varchar(20), data varchar(20), index_size varchar(20), unused varchar(20))
exec sp_MSforeachtable "insert into #t exec sp_spaceused '?'"
select * from #t order by data desc
drop table #t