Submit a ticketCall us

Get a crash course on Network Monitoring delivered right to your inbox
This free 7-day email course provides a primer to the philosophy, theory, and fundamental concepts involved in IT monitoring. Lessons will explain not only how to perform various monitoring tasks, but why and when you should use them. Sign up now.

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

Remove IPAM from the database

Table of contents

 

Created by Matthew Lamb, last modified by Jane Baylon on Jul 18, 2016

Views: 34 Votes: 0 Revisions: 13

Overview

This article provides steps to removing IPAM tables, views, functions and procedure from a customer's database. 

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

Environment

IPAM version 2 and later

Steps

Warning:
SolarWinds strongly recommends that you create a backup of your data. Executing the following steps will remove all IPAM functions from your database. 

1. Open SQL Management Studio.

2. Run Query 1.

3. Refresh the database to verify if the IPAM tables, views, and functions are still present. 

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

4. Run Query 2.

Note: 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.

Warning:
SolarWinds strongly recommends that you create a backup of your data. Executing the following steps will remove all IPAM functions from your database. 

 

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
13:26, 18 Jul 2016

Tags

Classifications

Public