Solved

SQL Server 2005 - Copy Database on to same server

Posted on 2006-07-07
9
645 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
  • 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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 SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now