| Author |
Topic |
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-14 : 22:08:05
|
| Hi,I'm found this sample for BACKUP DATABASE statement in SQL Server 2000 BookOnline, but is seemed that only save file to server. How can I save backupfile to local computer? or there is other way as easy as this statement forbackup/restore database?-- Create a logical backup device for the full MyNwind backup.USE masterEXEC sp_addumpdevice 'disk', 'MyNwind_1',DISK ='c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_1.dat'-- Back up the full MyNwind database.BACKUP DATABASE MyNwind TO MyNwind_1Thanks,Tien, |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-01-15 : 02:19:43
|
| You can save to another computer by replacing "c:\" with "\\servername\". The account that runs the backup though, which is probably the same one running the SQL Server or SQL Server Agent service needs to have write/read access on the share you are writing the backup to.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-01-15 : 06:38:26
|
| What will happen if the backup routine can't find the share one day? Quite possibly "no backup" and "no alert", unless you are sure that your alerting system is bulletproof.I would suggest you backup to local server, and then copy to remote machine (or even MOVE to remote machine - at least if that fails the backup will be left on server)You can do the COPY/MOVE, after the backup, using EXEC master.dbo.xp_cmdshell 'COPY c:\path\MyBackupFile.BAK \\MyServer\MyShare'Kristen |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
|
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-16 : 20:51:10
|
| Thanks nr, but page not found error! |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-16 : 20:58:02
|
| Try it again - and post if you still get an error.It's ok for me.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-17 : 03:45:05
|
| I still can't access these pages, don't know why :( |
 |
|
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-18 : 03:44:46
|
| When I restore database with RESTORE DATABASE, there is an error:Exclusive access could not be obtained because the database is in use. RESTORE DATABASE is terminating abnormally.What does it mean? I'm only one user connect to this server at this time.What are conditions to perform restore database?thanks, |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-01-18 : 14:01:04
|
| "What does it mean? I'm only one user connect to this server at this time."Are you connected to the database you are trying to restore to?Put aUSE MASTERGOin front of your RESTORE commandIf others MAY be connecting to the database use:ALTER DATABASE MyDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE(EDIT: This will kill any open connections and rollback their transactions)Kristen |
 |
|
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-18 : 20:15:31
|
| thanks, I will try it all,this is testing time, so there is only me accessing this database, and my application is connection-less, which don't keep any connection open longer 5 seconds.in fact, for executing RESTORE statement, I've connect to database using connection string like "DataSource=(local);Initial Catalog=master;..." do I have to use "USE MASTER" more?thanks, |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-18 : 21:09:13
|
| A lot of providers will leave the connection accessing a different database if the login doesn't have access to the requested one without giving an error.In query analyser try select * from master..sysprocesses where dbid = db_id('mydbname')to see if anything is connected to the database (it's often enterprise manager if you have used that.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|