Submit a ticketCall us

whitepaperYour VM Perplexities Called, and They Need You to Read This.

Virtualization can give you enormous flexibility with future workloads and can be a key enabler for other areas, like cloud computing and disaster recovery. So, how can you get a handle on the performance challenges in your virtual environment and manage deployments without erasing the potential upside? Learn the four key areas you need to be focusing on to help deliver a healthy and well-performing data center.

Get your free white paper.

Home > Success Center > IP Address Manager (IPAM) > IPAM - Knowledgebase Articles > Remove IPAM from the database

Remove IPAM from the database

Created by Matthew Lamb, last modified by Nigel on Sep 10, 2018

Views: 1,249 Votes: 1 Revisions: 16

Last updated: 9/10/18

Overview

This article describes how to remove IPAM tables, views, functions and procedure from a customer's database. 

Environment

IPAM version 2 and later

Steps

SolarWinds strongly recommends that you create a backup of your data. Executing the steps below could result in data loss. 

  1. Open SQL Management Studio.
  2. Run Query 1 (shown below).
  3. Refresh the database to verify if the IPAM tables, views, and functions are still present.

    Run the following query if the IPAM functions are still present after Query 1 is finished. 

  4. Run Query 2 (shown below).

    Running Query 2 will result to another set of queries.

  5. Copy the results from Query 2.
  6. Open a new query and paste the results of Query 2.
  7. Run the new query. This will remove all procedures.

 

Query 1:

DECLARE @table_object_id int
DECLARE @table_name varchar(max)
DECLARE @table_type varchar(max)
DECLARE @fk_name varchar(max)
DECLARE @fk_parent_name 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
JOIN sys.schemas s ON o.schema_id=s.schema_id
WHERE s.name='dbo' AND o.[type] IN ('U','V') AND o.name LIKE 'IPAM%'

OPEN table_cursor

FETCH NEXT FROM table_cursor INTO @table_object_id, @table_name, @table_type
WHILE @@FETCH_STATUS=0
BEGIN

    DECLARE fk_cursor CURSOR FAST_FORWARD FOR
    SELECT fk.name, parent.name
    FROM sys.foreign_keys fk
    JOIN sys.objects parent ON fk.parent_object_id=parent.object_id
    JOIN sys.schemas fk_s ON fk.schema_id=fk_s.schema_id
    JOIN sys.schemas parent_s ON parent.schema_id=parent_s.schema_id
    WHERE fk_s.name='dbo' AND parent_s.name='dbo' AND fk.referenced_object_id=@table_object_id

    OPEN fk_cursor

    FETCH NEXT FROM fk_cursor INTO @fk_name, @fk_parent_name
    WHILE @@FETCH_STATUS=0
    BEGIN

 

SET @stmt = 'ALTER TABLE [dbo].['+@fk_parent_name+'] DROP CONSTRAINT ['+@fk_name+']'
EXEC [dbo].sp_executesql @statement = @stmt

            FETCH NEXT FROM fk_cursor INTO @fk_name, @fk_parent_name

    END

    CLOSE fk_cursor
    DEALLOCATE fk_cursor

    SET @stmt = CASE @table_type WHEN 'V' THEN 'VIEW' ELSE 'TABLE' END
    SET @stmt = 'DROP '+@stmt+' [dbo].['+@table_name+']'
    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'[dbo].[IPAM_GetDbVersion]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetDbVersion]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetAvailableScopeRatio]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetAvailableScopeRatio]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetIPOrd]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetIPOrd]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetPoolData]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetPoolData]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetScopeChartData]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetScopeChartData]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetScopeColumn]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetScopeColumn]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_GetScopeIPRanges]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_GetScopeIPRanges]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_ReverseIP]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[IPAM_ReverseIP]
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[IPAM_VendorIcon]') AND xtype in (N'FN', N'IF', N'TF'))

    DROP FUNCTION [dbo].[IPAM_VendorIcon]

 

Query 2:

Select 'drop procedure' + name from sys.procedures where name like '%IPAM'

 

 

 

 

Last modified

Tags

Classifications

Public