Submit a ticketCall us

Webinar: Web Help Desk for HR, Facilities and Accounting Departments
This webinar will focus on use cases for HR, Facilities and Accounting.

Having a unified ticketing and asset management system for all the departments in your company can provide end-users with a seamless experience and make things easier for your IT team. Yet, with different business tasks and objectives, many departments don’t fully understand the capabilities of Web Help Desk and how the software can be customized for effective use in their departments.
Register Now.

Home > Success Center > Network Performance Monitor (NPM) > Drop multiple stored procedures in the Orion database

Drop multiple stored procedures in the Orion database

Table of contents
Created by Mariusz Handke, last modified by MindTouch on Jun 23, 2016

Views: 17 Votes: 1 Revisions: 7

Overview

This article provides information on how to drop multiple (or all) stored procedures in the database. This is useful while upgrading Orion and facing issues with some stored procedures not being able to be modified or recreated.

Environment

All Orion Platform versions

Steps

The following steps allow you to create set of queries which can be executed, resulting in dropping specified stored procedures (in example below: stored procedures which names starts with dbm_):

  1. Make sure to backup database, although dropping views has no impact on stored data.
  2. Open SQL Server Management Studio (SSMS).
  3. Use below query to drop stored procedures.
    use YOUR-DB-NAME /* put your database name here */
    GO
    DECLARE @sql VARCHAR(MAX) = ''
    DECLARE @CRLF VARCHAR(2) = CHAR(13) + CHAR(10)
    SELECT @sql = @sql + 'DROP PROCEDURE ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(o.[name]) +';' + @CRLF
    FROM sys.objects o
    WHERE o.[type]='p' AND o.[name] LIKE 'dbm_%'
    EXEC(@sql);

    NOTE:
    You can use your own criteria to specify stored procedures name (pattern) or skip the WHERE clause to drop all views.
  4. Run Configuration Wizard, selecting option Database otherwise Orion will not work.

 

You can also preview the final command, without execution. To do so, replace:

EXEC(@sql);

with

PRINT(@sql);
Last modified
22:12, 22 Jun 2016

Tags

Classifications

Public