I have group of stored procedures with names like 'somename_%'. Are there any way to delete that SP with one query, forexample
DROP PROCEDURE where name like 'somename_%'
.
This works for MSSQL 2005 +
DECLARE @DropScript varchar(max)
set @DropScript = ''
SELECT @DropScript = @DropScript + 'DROP PROCEDURE [' + schema_name(schema_id)+ '].' + '[' + name + ']
' FROM sys.procedures
where name like 'somename_%'
exec (@DropScript)
You can generate the DDL by querying the data dictionary. For example, in Oracle:
SELECT 'DROP PROCEDURE "'||owner||'"."'||object_name||'";'
FROM all_procedures
WHERE procedure_name IS NULL
AND lower(object_name) LIKE 'somename_%';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With