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