为了隐藏DBCC SHRINKFILE我试过的输出:
CREATE TABLE #Swallow(DbId int, Fileld int, CurrentSize int, MininumSize int, UsedPages int, EstimatedPages int)
INSERT INTO #Swallow EXEC('DBCC SHRINKFILE(''filename'', 0, TRUNCATEONLY)')
Run Code Online (Sandbox Code Playgroud)
但它返回以下错误:
无法在用户事务中执行shrinkfile操作.终止事务并重新发出该语句.
如何才能做到这一点?
似乎有一个WITH NO_INFOMSGS选择:
DBCC SHRINKFILE('filename', 0, TRUNCATEONLY) WITH NO_INFOMSGS
Run Code Online (Sandbox Code Playgroud)
参考:http://ss64.com/sql/dbcc_shrinkfile.html