Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
Removes one or more stored procedures or procedure groups from the current database in SQL Server.
Transact-SQL syntax conventions
Syntax for SQL Server, Azure SQL Managed Instance, and Azure SQL Database:
DROP { PROC | PROCEDURE } [ IF EXISTS ] { [ schema_name. ] procedure } [ , ...n ]
Syntax for Azure Synapse Analytics, Analytics Platform System (PDW), and Microsoft Fabric:
DROP { PROC | PROCEDURE } { [ schema_name. ] procedure_name }
Applies to: SQL Server 2016 (13.x) and later versions, Azure SQL Managed Instance, and Azure SQL Database
Conditionally drops the procedure only if it already exists.
The name of the schema to which the procedure belongs. A server name or database name can't be specified.
The name of the stored procedure or stored procedure group to be removed. Individual procedures within a numbered procedure group can't be dropped; the whole procedure group is dropped.
Before removing any stored procedure, check for dependent objects and modify these objects accordingly. Dropping a stored procedure can cause dependent objects and scripts to fail when these objects aren't updated. For more information, see View the Dependencies of a Stored Procedure
To display a list of existing procedures, query the sys.objects
catalog view. To display the procedure definition, query the sys.sql_modules
catalog view.
Requires CONTROL
permission on the procedure, or ALTER
permission on the schema to which the procedure belongs, or membership in the db_ddladmin fixed server role.
The following example removes the dbo.uspMyProc
stored procedure in the current database.
DROP PROCEDURE dbo.uspMyProc;
GO
The following example removes several stored procedures in the current database.
DROP PROCEDURE
dbo.uspGetSalesbyMonth,
dbo.uspUpdateSalesQuotes,
dbo.uspGetSalesByYear;
The following example removes the dbo.uspMyProc
stored procedure if it exists but doesn't cause an error if the procedure doesn't exist. This syntax was introduced in SQL Server 2016 (13.x).
DROP PROCEDURE IF EXISTS dbo.uspMyProc;
GO
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today