Submit a ticketCall us

Don’t fall victim to a ransomware attack
Backups are helpful, but sometimes that’s not enough to protect your business against ransomware. At our live webcast we will discuss how to protect against ransomware attacks with SolarWinds® Patch Manager and how to leverage log data to detect ransomware. Register now for our live webcast.

Home > Success Center > VoIP & Network Quality Manager (VNQM) > Remove the VNQM Database

Remove the VNQM Database

Table of contents
Created by Matthew Lamb, last modified by MindTouch on Jun 16, 2016

Views: 39 Votes: 1 Revisions: 3

Overview

This article goes over how to clear out the VNQM database fully from the SQL server.

Note: This query removes all VNQM data, tables, views, functions and procedures. Please ensure you backup your database ahead of time in the event an incident occurs.

Environment

VNQM version 4+

Steps

Here is the query to remove the VNQM database and all it's components from your SQL server.

  1. Run this query directly from the SQL server using SQL Management Studio.
  2. Enter the following.

-- WARNING: BE CAREFUL USING THIS SCRIPT !!!
-- THIS SCRIPT REMOVES ALL Voip* TABLES FROM THE DATABASE. THIS CAUSES LOSE OF ALL VNQM DATA INLCUDING IPSLA SITES, IP SLA OPERATIONS, CALL MANAGERS AND STATISTICS !!!
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 'Voip%'
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].[GetVoipDbVersion]') AND xtype in (N'FN', N'IF', N'TF'))
    DROP FUNCTION [dbo].[GetVoipDbVersion]

 

 

 

Last modified
16:32, 16 Jun 2016

Tags

Classifications

Public