Reindexing in MSSQL Express
-
On the Windows Server on which the MSSQL Express Server is installed, create a new task in the Windows Task Scheduler
-
Set the schedule to Daily (e.g. 4 a.m.) and select a service user who has the rights to run programs
-
Create a new action in the Actions tab and add Program/Script and Argument:
Program/ScriptC:\Windows\SysWOW64\cmd.exe
Add arguments/c "C:\Scripts\reindex.cmd"
-
Create a new Scripts folder in the directory under C:\
-
Download the following files from this link and add them to the Scripts folder:
-
reindex.cmd
-
Reindex.sql
-
-
Open the file reindex.cmd with a text editor and adjust the following line:
osql -Usa -Ppasswordsa -WserverSql\SQLExpress -i C:\Scripts\Reindex.sql >> %logfile%
Enter the password of the user SA and the name of the SQL server.
-
Execute the task in the Windows task scheduler. This creates the Reindex.log file in the C:\Scripts directory