Go to previous topic
Go to next topic
Last Post 9/5/2011 5:33 PM by  Dennis Odri
Manually re-indexing and updating stats on SQL Express.
 0 Replies
AddThis - Bookmarking and Sharing Button
Author Messages
Dennis Odri
HelpMaster tech support
Helpdesk leader
Helpdesk leader
Posts:45
Points:81


--
9/5/2011 5:33 PM

    The SQL Server 2008 R2 Express edition that comes with HelpMaster doesn't have the capabitilty to perform maintenance tasks such as automated Database backups, re-indexing, and updating statistics to keep your database lean and performing well. There are however built-in Stored Procedures and functions that can be run manually on a regular basis to perform these tasks. Run each of the following SQL sections in order from SQL Server Management Studio Express, if installed. Alternately you can run it from the HelpMaster Database and Reports Wizard using Database Tools under the Execute SQL tab but can exclude the 'USE MyDatabase' statement from each section as your databse has already been selected in a previous step. Hope this helps those using SQL Server Express editions with Helpmaster. Don't forget to replace 'MyDatabase' with the name of your own HelpMaster database.

    -- This part checks database integrity including indexes --
    USE
    MyDatabase
    DBCC CHECKDB(N'MyDatabase'WITH NO_INFOMSGS

    -- This part rebuilds the database indexes --
    USE MyDatabase
    EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"

    -- This part backs up your database to the specified location with the specified backup name --
    BACKUP DATABASE MyDatabase
    TO  DISK = N'C:\HelpMaster DB Backups\Weekly Backups\MyDatabase_backup_2011_09_06.bak'
    WITH NOFORMAT, NOINIT,  NAME = N'MyDatabase_backup_2011_09_06',
    SKIP, REWIND, NOUNLOAD,  STATS = 10

    -- This part updates database statistics --
    USE MyDatabase
    EXEC
    sp_updatestats



    ---