Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Edit all views and stored Procedures

Posted on 2011-09-07
4
Medium Priority
?
328 Views
Last Modified: 2012-05-12
We are planning to migrate to SQL Server 2008 from 2005. We also wanted to change the database names while doing this.But the problem is, we have these database names hard-coded in the views and stored procedures.
Can we write a script to rename all the database names inside these views and stored procedure instead of going to each one of them and change it ?
I tried to Generate scripts using SSMS for all the ones that I need to change and replaced the database names using the text editor and then ran this script in Management Studio which did not work.
Any ideas ?

Thanks,
TH

0
Comment
Question by:supportrp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 15

Assisted Solution

by:Faiga Diegel
Faiga Diegel earned 668 total points
ID: 36497022
0
 
LVL 6

Accepted Solution

by:
markterry earned 668 total points
ID: 36497026
That should work.

First off ... Do a backup.

Generate Scripts, then change the database name on the actual database, then do a find and replace on the generated script (must be an overwriting script, like drop and create, or alter) and replace prior database name with new database name.

This will not work if you do not change the database name before running the script.
0
 
LVL 5

Assisted Solution

by:DavidMorrison
DavidMorrison earned 664 total points
ID: 36497031
Hi

In ssms right click the DB, select tasks then generate scripts. this will let you script the entire DB into a new query window. Once it has done this just do a find and replace of the old DB name to the new one and you're done

Thanks

Dave
0
 
LVL 1

Author Closing Comment

by:supportrp
ID: 36498923
Synonym option doesn't work for my scenario though it is one of the ways. I will have to try the other option after the migration. But I am sure this will work.

Thanks for the quick responses!


TH
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question