Submit a ticketCall us

Have You Auto Renewed? If not, you're missing out.
The SolarWinds Renewal Program comes with a host of benefits including the most recent product updates, 24/7 technical support, virtual instructor-led training and more. Experience all of this with the convenience of Auto Renewal, and never worry about missing any of these great benefits. Learn More.

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: 156 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

Tags

Classifications

Public