SQL Clone
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
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 81
Yes after the re-name has occured if you alter procedure then it will update the syscomments

Moe M
Database Consultant
http://www.cubeangle.com
Brandie Tarvin
Brandie Tarvin
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39346 Visits: 9291
But if you're going to rename and alter, you might as well just drop and create. It's cleaner.

Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
Moe M
Moe M
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 81
Agreed. DROP/CREATE is also easier to be put in a script

Moe M
Database Consultant
http://www.cubeangle.com
SanjayAttray
SanjayAttray
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5797 Visits: 1619
For the same reason I never use sp_rename to rename object in sql server.

Always prefer if exist method.

if exists (select * from sys.objects where object_id = object_id(N'[dbo].[Object_name]') and OBJECTPROPERTY(object_id, N'IsProcedure') = 1)
drop procedure [dbo].[object_name]
GO
Create procedure dbo.object_name
as

SQL DBA.
UMG Developer
UMG Developer
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4144 Visits: 2204
Nice article, I think it is good to bring light to this situation.

However, I think it is interesting that you only found the problem because of bad data on a report. Does your application to copy the database not report the errors it encounters while transferring objects? (Proper error handling could have saved you hours of investigation.)
Moe M
Moe M
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 81
UMG Developer (10/7/2010)
Nice article, I think it is good to bring light to this situation.

However, I think it is interesting that you only found the problem because of bad data on a report. Does your application to copy the database not report the errors it encounters while transferring objects? (Proper error handling could have saved you hours of investigation.)


Well as far as the application is concerned no error has occured here. The SQLDMO pulled all objects and scripted them successfully. Only when running the generated script have you the chance to check the errors and see if any of your create statements have failed due to duplicate create statements and of course we failed at this point.

Moe M
Database Consultant
http://www.cubeangle.com
UMG Developer
UMG Developer
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4144 Visits: 2204
Mohammad Meimandi (10/7/2010)[hrWell as far as the application is concerned no error has occured here. The SQLDMO pulled all objects and scripted them successfully. Only when running the generated script have you the chance to check the errors and see if any of your create statements have failed due to duplicate create statements and of course we failed at this point.


OK, I thought that the application generated and executed the scripts, but I see I missed the part that you run the scripts manually.
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68719 Visits: 18570
Thanks for the article.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

davepaulino
davepaulino
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 0
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!
Moe M
Moe M
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 81
CirquedeSQLeil (10/7/2010)
Thanks for the article.


Thanks for reading it!

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