February 3, 2010 at 12:01 am
Comments posted to this topic are about the item A Search and Replace Script when Moving Objects from Prod to Test
February 3, 2010 at 7:51 am
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
February 3, 2010 at 7:53 am
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.
February 3, 2010 at 8:01 am
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.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
February 3, 2010 at 8:08 am
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.
February 3, 2010 at 8:29 am
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
February 3, 2010 at 8:32 am
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
February 3, 2010 at 12:35 pm
Ben,
Thanks for the article. I have to agree with the others, sometimes the hoops we jump through (to make our job a little easier) are astounding. Nice solution.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 3, 2010 at 12:38 pm
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
February 3, 2010 at 12:47 pm
bkubicek (2/3/2010)
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
I have yet to see one of their shows "live." I like very much what they do/achieve. I thought it was fitting with location and job.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 3, 2010 at 1:04 pm
I have yet to see one of their shows "live." I like very much what they do/achieve. I thought it was fitting with location and job.
Jason,
I had the opportunity to see them twice. I have heard the show in Las Vegas is really crazy since they have water all over the place and you never know when they are diving into the water or landing on the stage.
You are right sometimes work can be a circus.
Ben
February 3, 2010 at 1:12 pm
I guess I was wrong about seeing their show live. I just remembered that they have a show at SeaWorld too.
I will have to get down to the strip and catch one of their shows sometime.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 3, 2010 at 1:20 pm
Do you live in San Diego? I grew up there. Or perhaps you live in Orlando.
Ben
February 3, 2010 at 3:03 pm
Nope. LV. Visited San Diego last summer.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 3, 2010 at 4:57 pm
Dont like the cumbersome approach in this article. We use Linked Servers, although aliases would be better.
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply