Submit a ticketCall us

WebinarUpcoming Webinar: Should I Move My Database to the Cloud?

So you’ve been running an on-premises SQL Server® for a while now. Maybe you’ve moved it from bare metal to a VM, and have seen some positive benefits. But, do you want to see more? If you said “YES!”, then this session is for you, as James Serra will review the many benefits that can be gained by moving your on-prem SQL Server to an Azure® VM (IaaS). He’ll also talk about the many hybrid approaches, so you can gradually move to the cloud. If you are interested in cost savings, additional features, ease of use, quick scaling, improved reliability, and ending the days of upgrading hardware, this is the session for you.

Register now.

Home > Success Center > VoIP & Network Quality Manager (VNQM) > VNQM - Knowledgebase Articles > Remove the VNQM database from the SQL server

Remove the VNQM database from the SQL server

Table of contents

Overview

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

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

Environment

VNQM version 4.x

Steps

The query below removes the VNQM database and all it's components from your SQL server.

Run the following query directly from the SQL server using SQL Management Studio:

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

Tags

Classifications

Public