|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, February 01, 2013 8:13 AM
Points: 1,488,
Visits: 388
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, November 15, 2012 9:41 PM
Points: 1,
Visits: 161
|
|
Sigh...the ideas we need to come up with sometimes to make things easier. Thanks for the post Ben.
Thankfully MS added Synonyms to SQL Server 2005 to make this process easier for everyone.
-James
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, December 13, 2012 7:23 AM
Points: 22,
Visits: 349
|
|
Thanks for the article. I had to do a similar thing for our development and test environment. We have two databases in production that have views that point to the other database. Therefore, if we wanted to run 2 separate copies of these databases, we'd run into hardcoded names in the procedural code. So I wrote a similar script to make the changes.
FYI, I used the Sys.Sql_Modules catalog view instead of sp_helptext.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 9:57 AM
Points: 895,
Visits: 504
|
|
We have a similar situation using SS2005, however we use synonyms. When I worked on SS2000, I used linked databases to provide a layer of abstraction.
"...when ye are in the service of your fellow beings ye are only in the service of your God." -- Mosiah 2:17
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, December 13, 2012 7:23 AM
Points: 22,
Visits: 349
|
|
I agree that there are better solutions, this script helps you when you have a legacy system that you didn't design. We all have those.
Btw, be careful with the replace command. If you have "CREATE TABLE" statements in your stored procedures, this will change them to "ALTER" table statements. I solved this by finding the words CREATE PROCEDURE, CREATE PROC, CREATE TRIGGER, CREATE FUNCTION, etc with several variations (like 2 and 3 spaces between the words -- remember I didn't write these!). Regular expressions might be a better solution, but mine works.
I made sure that my script replaced all known variations in production until the changed rows matches the number of procedures in production.
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, February 01, 2013 8:13 AM
Points: 1,488,
Visits: 388
|
|
Hey James, glad you liked the article. I was pretty happy when I figured this out. I had been thinking about a solution to this for some time. It was nice when I finally figured one out. Ben
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, February 01, 2013 8:13 AM
Points: 1,488,
Visits: 388
|
|
Thanks for your suggestions on the replace. I did feel that part of the code was a little weak. Perhaps your suggestions will be in version two of this script. Ben
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, February 01, 2013 8:13 AM
Points: 1,488,
Visits: 388
|
|
Hey Jason,
I am glad you liked the article. By the way I like your sqlservercentral name. CirquedeSQLeil is very clever. I have seen their show, it was enjoyable.
Ben
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|