Submit a ticketCall us

Looking to compare latest NPM features with previous versions of NPM?
The NPM new feature summary offers a comparison of new features and improvements offered with this release.

 

Home > Success Center > Server & Application Monitor (SAM) > Remove orphaned SAM database objects after uninstalling evaluation version

Remove orphaned SAM database objects after uninstalling evaluation version

Table of contents
Created by Mariusz Handke, last modified by Rodim Suarez on Jun 29, 2016

Views: 19 Votes: 2 Revisions: 7

Updated June 2, 2016

Overview

This article provides instruction on how to remove orphaned SAM database objects after uninstalling the evaluation version. Leaving such objects may result in compatibility error while upgrading other SolarWinds applications.

Environment

Any Orion Platform versions

Steps

Note: Before making any manual changes to the database make sure to backup database.

  1. Log into the SolarWinds server.

  2. Open the Orion Database Manager.

  3. Expand the Server.
  4. Expand the Orion Database.
  5. Double-click any table.
  6. Overwrite existing query with below query:
     
    /*
    
    Warning: This script removes ALL APM (SAM) structures and data from database !!!
    
    'FN','IF'..scalar valued functions
    'TF'..table valued functions
    'P'..procedure
    'U'..TABLE
    'V'..View
    */
    
    DECLARE @table_object_id int
    DECLARE @table_name varchar(max)
    DECLARE @table_type varchar(max)
    DECLARE @stmt nvarchar(max)
    
    DECLARE table_cursor CURSOR FAST_FORWARD FOR
    SELECT o.object_id, o.name, o.[type]
    FROM sys.objects o
    WHERE o.[type] IN ('FN','TF','V','P','U') AND o.name LIKE 'APM_%' AND o.name NOT LIKE '%APM_Hardware%'
    ORDER BY CASE o.[type] WHEN 'U' THEN 'z' ELSE o.[type] END
    
    OPEN table_cursor
    
    FETCH NEXT FROM table_cursor INTO @table_object_id, @table_name, @table_type
    WHILE @@FETCH_STATUS=0
    BEGIN
    
    SET @stmt = CASE @table_type
        WHEN 'V' THEN 'VIEW'
        WHEN 'P' THEN 'PROCEDURE'
        WHEN 'FN' THEN 'FUNCTION'
        WHEN 'TF' THEN 'FUNCTION'
        ELSE 'TABLE'
        END
    
        SET @stmt = 'DROP '+@stmt+' ['+@table_name+']'
        PRINT @stmt
        EXEC [dbo].sp_executesql @statement = @stmt
    
        FETCH NEXT FROM table_cursor INTO @table_object_id, @table_name, @table_type
    END
    
    CLOSE table_cursor
    DEALLOCATE table_cursor
    
    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[GetApmDbVersion]') AND xtype in (N'FN', N'IF', N'TF'))
    BEGIN
        DROP FUNCTION GetApmDbVersion
    END

    Note: To copy content without line numbers, hover over the text and click the view source button (View Source). This opens a new window where you can select and copy text without any formatting or line numbering.

     

  7. Click Execute Query.
  8. Close Database Manager.

 

Last modified
19:06, 28 Jun 2016

Tags

Classifications

Public