SQL Server Bulk Delete stored procedures and batch modify stored procedures statements _mssql

Source: Internet
Author: User
Modify:
Copy Code code as follows:

DECLARE proccur cursor
For
Select [Name] from sysobjects where name like ' foods_% '
DECLARE @procname varchar (100)
DECLARE @temp varchar (100)
Open Proccur
FETCH NEXT from Proccur into @procname
while (@ @FETCH_STATUS = 0)
Begin
Set @temp = ' kcb_ ' + @procname
EXEC sp_rename @procname, @temp

Print (@procname + ' has been deleted ')
FETCH NEXT from Proccur into @procname
End
Close Proccur
Deallocate proccur

DECLARE proccur cursor
For
Select [Name] from sysobjects where name like ' kcb% '
DECLARE @procname varchar (100)
DECLARE @temp varchar (100)
DECLARE @temp2 varchar (100)
DECLARE @temp3 varchar (100)
Open Proccur
FETCH NEXT from Proccur into @procname
while (@ @FETCH_STATUS = 0)
Begin
Set @temp3 = LEN (@procname)
Set @temp = ' Kcb_ '
Set @temp2 =right (@procname, @temp3-3)
Set @temp + + @temp2
EXEC sp_rename @procname, @temp

Print (@procname + ' has been modified ')
FETCH NEXT from Proccur into @procname
End
Close Proccur
Deallocate proccur

Delete:
Copy Code code as follows:

DECLARE proccur cursor
For
Select [Name] from sysobjects where name like ' users_% '
DECLARE @procname varchar (100)
Open Proccur
FETCH NEXT from Proccur into @procname
while (@ @FETCH_STATUS = 0)
Begin
EXEC (' drop proc ' + @procname)
Print (@procname + ' has been deleted ')
FETCH NEXT from Proccur into @procname
End
Close Proccur
Deallocate proccur
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.