How to delete procedures, user functions or views from a database in SQL?
DECLARE
@procedureName
varchar
(500)
DECLARE
cur
CURSOR
FOR
SELECT
[
name
]
FROM
sys.procedures
WHERE
type
in
(
'p'
,
'fn'
)
and
is_ms_shipped=0
and
name
not
like
'sp[_]%diagram%'
OPEN
cur
FETCH
NEXT
FROM
cur
INTO
@procedureName
WHILE @@fetch_status = 0
BEGIN
EXEC
(
'DROP PROCEDURE '
+ @procedureName)
--select @procedureName
FETCH
NEXT
FROM
cur
INTO
@procedureName
END
CLOSE
cur
DEALLOCATE
cur