Solved

SQL Server 2005 - Copy Database on to same server

Posted on 2006-07-07
9
682 Views
Last Modified: 2012-06-22
Hi,

I would like to make a copy of a sql server 2005 database and pop it on the same server.  I can't use the detact / attach method as the source database must not be taken offline.

I have tried the Copy Database Wizard but it errors, this is the message in the event log.

SQL Server Scheduled Job 'CDW_HHB_HHB_1' (0xDD5CBC096305DA4FA761440F930281F4) - Status: Failed - Invoked on: 2006-07-07 10:51:29 - Message: The job failed.  The Job was invoked by User HHB\Administrator.  The last step to run was step 1 (CDW_HHB_HHB_1_Step).

In SQL Server 2000, i used to be able to copy objects in a DTS package (tables, views, stored procs).  

I have tried creating a new database and exporting from the source to this but it only copys the tables and views, not the stored procs.

Has anyone else managed to take a full copy of a database and successfully create a new replication database on the same server using SQL Server 2005?


Thanks
0
Comment
Question by:Jackass03
[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
  • 3
  • 3
9 Comments
 
LVL 12

Expert Comment

by:Einstine98
ID: 17057270
Yes, many times...

1. Create a new database
2. Script your first database
3. Run the script on the new database.
4. Copy your data.... using DTS wizard

0
 

Author Comment

by:Jackass03
ID: 17057355
How do I script the database?

thanks for your answer
0
 
LVL 12

Expert Comment

by:Einstine98
ID: 17057487
click on the database in Management studio, right click and you hae the option to script it
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 8

Expert Comment

by:Kobe_Lenjou
ID: 17057943
You can also make a backup of the DB, amd restore it as a new DB
0
 

Author Comment

by:Jackass03
ID: 17058504
Hi

I have tried scripting the database and running the script in the new database.  However it seems to produce some errors and not create all the stored procs.  I have set the script to 'script all objects' but it doesnt seem to work ok.

Einstine98 - when you have done it in the past has your script produced errors when you have run it for your new database?

Thanks
0
 

Author Comment

by:Jackass03
ID: 17058601
Kobe_Lenjou

If I try and restore the database from a backup as a new database it errors because of the difference in the database names.

Any more ideas?
0
 
LVL 12

Accepted Solution

by:
Einstine98 earned 50 total points
ID: 17061571
If you restore the database under a different name you may get the SID of the database conflicting... coming from Oracle background I just wouldn't do it on the same server :-)

The script all objects option does fail (rarely would it work) and I have confirmed this as bug with Microsoft...

1. Script the database by selecting all the objects manually..
2. The scripts do give errors because of the stupid way it is ordered (dependency thing)...
3. Run the script two times on the same database, in the second time you should receive no errors (other than the object already exists).... if so, then you are 100% it's done...
4. Alternatively (and that's what I do for clients on 2005) work through the script and handle the dependencies (which table should be created before which view!)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

732 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