code for re-build index and shrink db or file?
We have issue to re-build index in large table. Will get insufficient disk space in filegroup 'PRIMARY'...error. So we have to manually shrink the database and re-build in the same time. How can we put the script together to do this automacally? And when I used shrinkdatabse, it only shrink the log file? And it seems we can't shrink unless we change the modle to simple. Do we use shrinkfile or shrinkdatabase? Is the syntax correct below? Thanks in advance!
ALTER INDEX ALL ON RD_WorkorderMart.dbo.WO_Star_Facts REBUILD;
ALTER DATABASE RD_WorkorderMart
SET RECOVERY SIMPLE
USE [RD_WorkorderMart]
GO
DBCC SHRINKDATABASE(N'RD_WorkorderMart', 10 )
GO
ALTER DATABASE RD_WorkorderMart
SET RECOVERY FULL
why shrinkfile will be better?
Hi, Rmia,
Could you explan why shinkfile will be better in this case? Do I need to change to simple before the shrinkfile or shrinkdatabase?