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
Solved

How to duplicate tables and/or db's, including all permissions, users, etc.?

Posted on 2008-06-23
7
270 Views
Last Modified: 2010-03-20
Hi Friends :-)

I'm a Flash/Flex developer, crossing over into .NET web apps.
I can't stop the SQL server, and prefer not to take anything off-line.
I have admin on IIS, and sa on SQL.
There are about 50 dbs on this server, so I want to minimize impact.
I just want tables and sometimes entire db's copied with new names, but with all the same data and permissions, etc., so that I can do testing with web code, and not worry about trashing or changing anything critical.

Any solid references with lots of detail are especially appreciated.  :-)

thanks!!
0
Comment
Question by:ksuchy
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:sbagireddi
ID: 21850560
Where you need entire databases the fastest way is to backup/restore.
Where you need only specific tables use the SSIS Import Export wizard.
0
 

Author Comment

by:ksuchy
ID: 21850602
Hi sbagireddi,

Thank you for this info.

However, isn't it a potential problem that the backup/restored db will have the same name when restored, right?  
Again, I'm doing this all live, and so I don't want the WORKING copies of tables and db's to be taken offline or disabled at any point in time, if possible.
I want my TESTING/DEVELOPMENT copies of tables and db's to have different names, than the ones currently used.

Kindest Regards,
K
0
 
LVL 8

Accepted Solution

by:
sbagireddi earned 500 total points
ID: 21850708
Since this is a production server and considering the enormity of the task, I would suggest you do it during  off-peak
hours.
Also database can be restored with a new name using the syntax below:

http://msdn.microsoft.com/en-us/library/aa238405(SQL.80).aspx

Look for "E. Make a copy of a database using BACKUP and RESTORE  ".

For tables you can change the name once the database has been restored using this syntax:
http://doc.ddart.net/mssql/sql70/sp_ra-rz_11.htm

But again please be forewarned that this is a prod env. I would do all this in a test environment and only if everything goes OK, do it in prod.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 8

Expert Comment

by:sbagireddi
ID: 21850716
Are you restoring on the same server or another one?
0
 

Author Comment

by:ksuchy
ID: 21850867
Same server.
I do have a test environ, with a very close replica machine.
I'll try it there first, then let you know how it goes.
0
 
LVL 8

Expert Comment

by:sbagireddi
ID: 21850886
Thats great.
0
 

Author Comment

by:ksuchy
ID: 21856233
http://www.databasejournal.com/features/mssql/article.php/3594201

First I ran a backup of the live operational db
Then I created a blank new db (with the suffice DEV on the name of the db)
When I restored, I used my new name, and checked the box in the second tab to force overwrite all stuff
I renamed tables I wanted to keep handy.
then I ran DTSWizard.exe to copy individual tables over from the live db to the backup copy.

took a few mistakes to realize that you have to close/open, or otherwise refresh Enterprise Manager, or the new tables don't show up.  Attempting to create a blank table from within the same DEV db, and then copy over data from good table (renamed) to the new blank table wouldn't work.  Also, you can't duplicate a table with source/destination both in the same db, because you can't get at the SQL or get the table copy to have a new name (it will just append or rewrite the same data within the same table).
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

860 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