Deleting Sage X3 folder from database

Dear Fellows,

As you may all know that when you delete a folder in X3 it will not be deleted from database with all its references which will eventually increase your database size, and therefore i created an sql procedure that safely delete the folder from database and would like to share it with you.

Sage X3 delete folder.docx  

Parents Reply Children
  • in reply to Sahem

    So I take it I need to change this:

     SELECT @SQL =  

     'SELECT

          CASE WHEN SO.type=''PK'' THEN '' ALTER TABLE ''+SCHEMA_NAME(SO.schema_id)+''.''+OBJECT_NAME(SO.parent_object_id)+'' DROP CONSTRAINT ''+ SO.name

               WHEN SO.type=''U'' THEN '' DROP TABLE ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]

               WHEN SO.type=''V'' THEN '' DROP VIEW  ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]

               WHEN SO.type=''P'' THEN '' DROP PROCEDURE  ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]         

               WHEN SO.type=''TR'' THEN ''  DROP TRIGGER  ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]

               WHEN SO.type  IN (''FN'', ''TF'',''IF'',''FS'',''FT'') THEN '' DROP FUNCTION  ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]

                       WHEN SO.type=''SO'' THEN ''  DROP SEQUENCE  ''+SCHEMA_NAME(SO.schema_id)+''.''+ SO.[Name]

           END

    The SO.[Name] to be the schema name, as in SO.SEED

  • in reply to martin2

    Sorted. Changed the @Foldername to be the schema name, and that cleared everything down. Tested on a VM, so all good.

    Thanks Sahem

  • in reply to martin2

    you are most welcome