-
-
Save sniffdk/abaf58942b35f7f2a2b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @RowCount int, @tablename varchar(100) | |
declare @Tables table ( | |
PK int IDENTITY(1,1), | |
tablename varchar(100), | |
processed bit | |
) | |
INSERT into @Tables (tablename) | |
SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE' and TABLE_NAME not like 'dt%' order by TABLE_NAME asc | |
declare @Space table ( | |
name varchar(100), rows nvarchar(100), reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100) | |
) | |
select top 1 @tablename = tablename from @Tables where processed is null | |
SET @RowCount = 1 | |
WHILE (@RowCount <> 0) | |
BEGIN | |
insert into @Space exec sp_spaceused @tablename | |
update @Tables set processed = 1 where tablename = @tablename | |
select top 1 @tablename = tablename from @Tables where processed is null | |
SET @RowCount = @@RowCount | |
END | |
update @Space set data = replace(data, 'KB', '') | |
update @Space set data = convert(decimal(10,2), data)/1000 | |
update @Space set data = data + 'MB' | |
update @Space set reserved = replace(reserved, 'KB', '') | |
update @Space set reserved = convert(decimal(10,2), reserved)/1000 | |
update @Space set reserved = reserved + 'MB' | |
select * from @Space order by convert(decimal(8,2), replace(data, 'MB', '')) desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER DATABASE [mydatabase] SET RECOVERY SIMPLE | |
DBCC SHRINKFILE(<log_file_name_Log>) | |
ALTER DATABASE [mydatabase] SET RECOVERY FULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment