web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

dereindex.sql script missing

(0) ShareShare
ReportReport
Posted on by

I'm trying to run the recommended SQL maintenance on my Dynamics GP databases.  Where can I find the reindex.sql and recomp.sql scripts if they are not in the c:\program files\microsoft dynamics\gp\sql\util folder?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Copy and paste the below into a query window and 'save as' into the utilities folder. 

     

    Recomp.sql

    /*Count : 2 */

    /*Begin_Recompile*/

    declare @cStatement varchar(255)

    declare T_cursor CURSOR for select 'sp_recompile [' + convert(varchar(64),name) + ']' from sysobjects where type = 'U' and uid = 1

    set nocount on

    OPEN T_cursor

    FETCH NEXT FROM T_cursor INTO @cStatement

    WHILE (@@FETCH_STATUS <> -1)

    begin

    EXEC (@cStatement)

    FETCH NEXT FROM T_cursor INTO @cStatement

    end

    DEALLOCATE T_cursor

    /*End_Recompile*/

    /*Begin_UpdateStats*/

    declare @cStats varchar(255)

    declare T_cursor CURSOR for select 'update statistics [' + convert(varchar(64),name) + ']' from sysobjects where type = 'U' and uid = 1

    set nocount on

    OPEN T_cursor

    FETCH NEXT FROM T_cursor INTO @cStats

    WHILE (@@FETCH_STATUS <> -1)

    begin

    EXEC (@cStats)

    FETCH NEXT FROM T_cursor INTO @cStats

    end

    DEALLOCATE T_cursor

    /*End_UpdateStats*/

     

     

    Reindex.sql

    /*Count : 1 */

    declare @tablename char(255)

    DECLARE t_cursor CURSOR for

    select 'DBCC DBREINDEX([' + o.name + '], '''', 0)'

    from

    sysobjects o, syscolumns c

    where o.id = c.id and o.type = 'U' and c.name like '%DEX_ROW_ID%'

    set NOCOUNT on

    open t_cursor

    FETCH NEXT FROM t_cursor INTO @tablename

    while (@@fetch_status <> -1)

    begin

    if (@@fetch_status <> -2)

    begin

    exec (@tablename)

    end

    FETCH NEXT FROM t_cursor into @tablename

    end

    DEALLOCATE t_cursor

     

    Supplied as is - check against a test database first to ensure the above is complete and you are happy with the results.

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
mtabor Profile Picture

mtabor 1

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans