??MSSQL????????????????????С
???????????? ???????[ 2013/5/6 10:43:17 ] ????????
???????????????????????????С????????????????????????????????????????????в?MSSQL?????????????????С?????????
????????????2??3?з?????????????????Щ?????????????????????AdventureWorks2012?????????????????е??????????????£?
View Code
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id?? N'IsUserTable') = 1)
create table tablespaceinfo --????????洢??
(nameinfo varchar(50) ??
rowsinfo int ?? reserved varchar(20) ??
datainfo varchar(20) ??
index_size varchar(20) ??
unused varchar(20) )
delete from tablespaceinfo --????????
declare @tablename varchar(255) --??????
declare @cmdsql varchar(500)
DECLARE Info_cursor CURSOR FOR
select o.name
from dbo.sysobjects o where OBJECTPROPERTY(o.id?? N'IsTable') = 1
and o.name not like N'#%%' order by o.name
OPEN Info_cursor
FETCH NEXT FROM Info_cursor
INTO @tablename
WHILE @@FETCH_STATUS = 0
BEGIN
if exists (select * from dbo.sysobjects where id = object_id(@tablename) and OBJECTPROPERTY(id?? N'IsUserTable') = 1)
execute sp_executesql
N'insert into tablespaceinfo exec sp_spaceused @tbname'??
N'@tbnamevarchar(255)'??
@tbname = @tablename
FETCH NEXT FROM Info_cursor
INTO @tablename
END
CLOSE Info_cursor
DEALLOCATE Info_cursor
GO
--itlearner??????????????
sp_spaceused @updateusage = 'TRUE'
--itlearner???????????
select *
from tablespaceinfo
order by cast(left(ltrim(rtrim(reserved)) ?? len(ltrim(rtrim(reserved)))-2) as int) desc
????????Ч???????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11