开发者

Copy database to another on same server

I have a database and want to copy its tables, etc, to another database, so I can use one of these databases as a "staging" DB.

What is the best/most foolproof way to 开发者_开发技巧do this?

Thanks


To be system agnostic... from any commandline:

sqldump -u username -p databasename > backup.sql;
sql -u username -p
<<provide password and access the sql commandline>>
create database newdatabasename;exit;

sql -u username -p newdatabasename < backup.sql

This should build a new database based on a backup of the older one


If you want to copy everything, I'd create a full backup of the DB you want to copy: Right click db > Tasks > Backup. Create an new db in SQL server and restore the backup file into it: right click > Tasks> Restore database. This will give you a full copy of the orignal DB.


You can just use: Right Click Database -> Tasks -> Copy Database...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜