Solved

Edit all views and stored Procedures

Posted on 2011-09-07
4
327 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 167 total points
ID: 36497022
0
 
LVL 6

Accepted Solution

by:
markterry earned 167 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 166 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all 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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

635 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