Contents tagged with reindex

  • How to shrink database of Acumatica with rebuilding of

    Hello everybody,

    today I want to leave another portion of SQL Server optimization for Acumatica database. In case if your db become huge, and you want to make it smaller, you can try following SQL code:

    DECLARE @Table NVARCHAR(128)  

    DECLARE @Database NVARCHAR(128)

    DECLARE @Command NVARCHAR(500)

    PRINT N'Shrinking database files'

    DBCC SHRINKDATABASE(0)

    PRINT N'Rebuilding all indexes'

    SET @Database = DB_NAME()

    SET @Command = 'DECLARE TableCursor CURSOR FOR SELECT ''['' + TABLE_CATALOG + ''].['' + TABLE_SCHEMA + ''].['' + 

        TABLE_NAME + '']'' as TableName FROM [' + @Database + '].INFORMATION_SCHEMA.TABLES 

        WHERE TABLE_TYPE = ''BASE TABLE'''   

    EXEC (@Command)  

    OPEN  … more