要先選好db再執行
--要先選好db再執行
DECLARE @DBNAME nvarchar(50)
select @DBNAME=DB_NAME()
--2.壓縮資料庫
DBCC SHRINKDATABASE(@DBNAME, 0 ,TRUNCATEONLY )
select @DBNAME=name from sys.database_files where type = 0
DBCC SHRINKFILE (@DBNAME , 1)
print convert(varchar,@DBNAME) +' done'
--3.取得資料庫Log檔檔案名稱
declare @LogFileName nvarchar(50)
select @LogFileName=name from sys.database_files where type = 1
--4.執行資料庫Log檔案壓縮
DBCC SHRINKFILE (@LogFileName, 0)
print convert(varchar,@LogFileName) +' done'
Taiwan is a country. 臺灣是我的國家