Reindex Database

  • Hi

    We have agresso business world that our accounts dept use. I am by no means proficient in the use of sql. The account dept say they need the database reindexed. They were told this by the people who put in the system. My question is do i just reindex everything. I am just not sure where to start!

    Any help appreciated.

    Thanks

    Claire

  • How big the database? If its a relatively small database with no high availability then you can reindex at day time but its prefered to do reindexing at night time or over week-ends when there were few or no users accessing database. Below script will reindex you complete database. Just schedule or execute this script in query analyzer. Best of luck.

    USE (database name)

    GO

    DECLARE @TableName varchar(255)

    DECLARE TableCursor CURSOR FOR

    SELECT table_name FROM information_schema.tables

    where TABLE_TYPE = 'BASE TABLE'

    OPEN TableCursor

    FETCH NEXT FROM TableCursor INTO @TableName

    WHILE @@FETCH_STATUS = 0

    BEGIN

    PRINT 'Reindexing ' + @TableName

    DBCC DBREINDEX(@TableName,' ',90)

    FETCH NEXT FROM TableCursor INTO @TableName

    END

    CLOSE TableCursor

    DEALLOCATE TableCursor

    SQL DBA.

  • Thanks for this - i will try it this weekend.

  • You need not reindex all the tables in the database. In your database there may be tables holding very small amount of data and these tables will have very little fragmentation.

    Identify tables that are used most for data modification and reindex them. Most probably this will be enough.

    "Keep Trying"

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply