.comment-link {margin-left:.6em;}

Ben Cops

Thursday, May 01, 2008

mattberther.com » Drop all stored procedures

mattberther.com » Drop all stored procedures:

A useful script to drop all sprocs (prior to updating them all, for example)

USE myDatabase
GO

declare @procName sysname

declare someCursor cursor FOR
SELECT name FROM sysobjects WHERE type = 'P' AND objectproperty(id, 'IsMSShipped') = 0

open someCursor
fetch next FROM someCursor INTO @procName
while @@FETCH_STATUS = 0
begin
exec('drop proc ' + @procName)
fetch next FROM someCursor INTO @procName
end

close someCursor
deallocate someCursor
go

0 Comments:

Post a Comment

<< Home