|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 2:46 PM
Points: 29,
Visits: 64
|
|
Yes after the re-name has occured if you alter procedure then it will update the syscomments
Mohammad Meimandi Database Consultant http://www.cubeangle.com
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:58 AM
Points: 6,655,
Visits: 5,678
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 2:46 PM
Points: 29,
Visits: 64
|
|
Agreed. DROP/CREATE is also easier to be put in a script
Mohammad Meimandi Database Consultant http://www.cubeangle.com
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
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.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
|
|
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.)
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 2:46 PM
Points: 29,
Visits: 64
|
|
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.
Mohammad Meimandi Database Consultant http://www.cubeangle.com
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
|
|
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.
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, October 07, 2010 11:14 PM
Points: 1,
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!
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 2:46 PM
Points: 29,
Visits: 64
|
|
CirquedeSQLeil (10/7/2010) Thanks for the article.
Thanks for reading it!
Mohammad Meimandi Database Consultant http://www.cubeangle.com
|
|
|
|