Solved

SQL Server 2005 - Copy Database on to same server

Posted on 2006-07-07
9
657 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

867 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

18 Experts available now in Live!

Get 1:1 Help Now