Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Potential Issue with Re-Naming Stored Procedures


Potential Issue with Re-Naming Stored Procedures

Author
Message
Moe M
Moe M
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 81
davepaulino (10/7/2010)
We also encountered this problem when we generate using sql compare application. Our workaround is to drop and recreate the procedure or functions. Great article!


Thanks!

Yes it's good to always stick to the best practices.

Moe M
Database Consultant
http://www.cubeangle.com
Andrew Novick
Andrew Novick
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 132
Yes, it's a problem. I submitted an item on Connect
https://connect.microsoft.com/SQLServer/feedback/details/398203/sp-rename-doesnt-change-the-text-of-udfs-or-procs-sp-helptext-then-returns-a-script-with-the-old-name
and it was classified as "Won't Fix"

It's something we're going to have to live with.

Regards,
Andy
Andrew Novick
SQL Server MVP
http://www.NovickSoftware.com
Hardy21
Hardy21
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1204 Visits: 1399
Andrew Novick (10/9/2010)
Yes, it's a problem. I submitted an item on Connect
https://connect.microsoft.com/SQLServer/feedback/details/398203/sp-rename-doesnt-change-the-text-of-udfs-or-procs-sp-helptext-then-returns-a-script-with-the-old-name
and it was classified as "Won't Fix"

It's something we're going to have to live with.

Regards,
Andy
Andrew Novick
SQL Server MVP
http://www.NovickSoftware.com


Thanks author for nice article.
I many times used sp_rename stored procedure but it is for our testing database. In production work, we always drop/create procedure with Grant so we did not face this issue, but good to know that if we are using 'syscomments' instead of 'sys_modules' anywhere in any script, it cause an issue.

Thanks
Moe M
Moe M
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 81
Andrew Novick (10/9/2010)
Yes, it's a problem. I submitted an item on Connect
https://connect.microsoft.com/SQLServer/feedback/details/398203/sp-rename-doesnt-change-the-text-of-udfs-or-procs-sp-helptext-then-returns-a-script-with-the-old-name
and it was classified as "Won't Fix"

It's something we're going to have to live with.

Regards,
Andy
Andrew Novick
SQL Server MVP
http://www.NovickSoftware.com


Thanks!

Yes it seems we have to deal with it our own way

Moe M
Database Consultant
http://www.cubeangle.com
Moe M
Moe M
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 81
Hardy21 (10/10/2010)
Andrew Novick (10/9/2010)
Yes, it's a problem. I submitted an item on Connect
https://connect.microsoft.com/SQLServer/feedback/details/398203/sp-rename-doesnt-change-the-text-of-udfs-or-procs-sp-helptext-then-returns-a-script-with-the-old-name
and it was classified as "Won't Fix"

It's something we're going to have to live with.

Regards,
Andy
Andrew Novick
SQL Server MVP
http://www.NovickSoftware.com


Thanks author for nice article.
I many times used sp_rename stored procedure but it is for our testing database. In production work, we always drop/create procedure with Grant so we did not face this issue, but good to know that if we are using 'syscomments' instead of 'sys_modules' anywhere in any script, it cause an issue.


Thanks for the comment!

On production the story is totally different. Normally there are regulations and checks in place to make sure these sort of issues don't occur.

Moe M
Database Consultant
http://www.cubeangle.com
Peter Petrov
Peter Petrov
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1274 Visits: 425
Nice finding! Good to know...

The script could be simplified (2005 and 2008):


SELECT OBJECT_NAME(object_id) AS proc_name
, object_id
, definition
FROM sys.sql_modules
WHERE PATINDEX('%CREATE%PROCEDURE%',definition) > 0
AND PATINDEX('%' + OBJECT_NAME(object_id) + '%', definition) = 0
ORDER BY OBJECT_NAME(object_id);





Moe M
Moe M
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 81
Peter Petrov (10/15/2010)
Nice finding! Good to know...

The script could be simplified (2005 and 2008):


SELECT OBJECT_NAME(object_id) AS proc_name
, object_id
, definition
FROM sys.sql_modules
WHERE PATINDEX('%CREATE%PROCEDURE%',definition) > 0
AND PATINDEX('%' + OBJECT_NAME(object_id) + '%', definition) = 0
ORDER BY OBJECT_NAME(object_id);



Thanks Peter,

Yes you are right. As mentioned in the article in 2005 and 2008 you don't have the problem of record size limitation therefore it is much easier to extract the rouge procedures.

Moe M
Database Consultant
http://www.cubeangle.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search