.

January 4, 2009

Delete all User stored procedure from SQL Server

hello friends.... if u want to try this code  then first take bakup your database.becauze all user stored procedures will be deleted after this query.


step 1: for  check your  all stored procedure name. run in query analyzer

SELECT name FROM sys.objects where type_desc ='SQL_STORED_PROCEDURE'

step 2: if step 1 is correct then run below code in query analyzer

Declare @sql Varchar(500)
Declare @get_table varchar(100)
DECLARE s_gettable CURSOR FOR SELECT name FROM sys.objects where type_desc ='SQL_STORED_PROCEDURE'              
     OPEN s_gettable
FETCH NEXT FROM s_gettable INTO @get_table
WHILE @@FETCH_STATUS = 0
BEGIN             
          BEGIN
Set @sql='drop procedure dbo.'+@get_table
exec(@sql)
          END
FETCH NEXT FROM s_gettable INTO @get_table 
END    
CLOSE s_gettable
    DEALLOCATE s_gettable

1 comment:

tushki said...

Nice Post Asha. I would love to hear more about ASP.NET and C#. You would also visit my blog for more APS.NET Articles, as we are working on same technology.