I have a test database that I need to export into our client's test environment.
This will be a one time only job.
I'm using SQL Server 2005 (My test db is SQL Server 2005 Express)
What is the best way to do this?
Backup the database in SSMS, and then restore the database on the target machine.
To do this in SSMS (SQL Server Management Studio), right click the database you want to backup select Tasks->Backup
, note the type of backup and the path of the .bak file. Then grab that file (the .bak) and go to the target database server / machine. Right click databases and do a "Restore"
.
Here you can tell it the path of the .bak file, and the database will be created on your clients machine with the name you specify.
If you really feel geeky you can write some T-SQL to backup and restore the database as well. Let me know if you feel real geeky and we can go this route as well...but it appears you are only doing this once so scripting is probably some overkill. But just in case anyone needs to backup a database, you can throw this in a procedure if you want:
DECLARE @strRootPath varchar(50)
DECLARE @BackupFile varchar(100)
DECLARE @strDB varchar(25)
SELECT @strRootPath = 'C:\SQL_BACKUPS\MyDBFolder\'
SELECT @strDB = db_name()
SELECT @BackupFile =
@strRootPath
+ db_name()
+ '_'
+ CONVERT(varchar(8), GetDate(), 112) -- yyyymmdd
+ '_'
+ REPLACE(LEFT(CONVERT(varchar(8), GetDate(), 108), 5), ':', '') -- hh:mm:ss
+ '.BAK'
BACKUP DATABASE @strDB TO DISK =@BackupFile WITH RETAINDAYS = 10, NAME = N'MyDB_DATA-Full Database Backup', STATS = 10
BACKUP LOG MyDB
TO MyDB_Log;
or maybe you can use SQL Server Management Studio (SSMS) then right click on database that you want to export so you will get new window for export-import database. fill any information for database connection and follow the steps until you success export it :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With