Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2004, 04:15 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default Backup database

I have formatted my hdd this recently, I forgot to backup my database (in fact, I don't know how), all the data are lost subsequently. I want to know how to backup my database to a different hard drive, and import it back from the drive where I back-up before, to the formatted drive when my OS is ready.

This is my second question:

My friend want me to give him a copy of my database (my database schema) because he want to use it, the problem is that he is staying far away from where I stay, and my friend don't want me to export data to him via internet as it is insecure. Any solution?

Thanks.

 
Old December 4th, 2004, 10:47 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Once you have SQL install and Patch with SP3A

Is your Drive on the same computer/Server?
If it is use this

Example to restore database

Code:
RESTORE DATABASE TestDB 
   FROM DISK = 'c:\Northwind.bak'
   WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
   MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'

To back up your database and give to a friend you have several options

Depending on its size make a back and burn it to a CD. You can also Zip or compress the backup file and then burn it to a cd. If you have Winzip you can encrypt it or password protect the file for email.
Example for backing up database
Code:
BACKUP DATABASE Northwind 
   TO DISK = 'c:\Northwind.bak'

Jaime E. Maccou
Applications Analyst
Database Programmer
 
Old December 4th, 2004, 01:12 PM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Hi, jemacc, I am not so clear about this:

 
Quote:
quote:RESTORE DATABASE TestDB
Quote:
   FROM DISK = 'c:\Northwind.bak'
   WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
   MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'


It is quite clear what the first line and second line are, but I am not so understand what the third and fourth line are. What does it means?

I know 'Northwind' and 'Northwind_log' are the backed-up database and its log, rite? But why move to 'c:\test\testdb.mdf' and 'c:\test\testdb.ldf'?

I have browsed through my C directories, I see there are numbers of database table and log file in this => C:\Program Files\Microsoft SQL Server\MSSQL\Data

If I follow yours example, is it correct if I code as this:

WITH MOVE 'Northwind' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data',
MOVE 'Northwind_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL\Data'[/quote]





 
Old December 4th, 2004, 01:34 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

The "move" . If you had your original database in a different folder or disk this will allow you to move the location of the data and log files. It is best practice not to have your application file and your data files in the same drive or location.

Code:
RESTORE DATABASE TestDB 
   FROM DISK = 'c:\Northwind.bak'
   WITH RECOVERY, REPLACE,
   WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
   MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'
With replace - this will wipe out all data files/log files and restore the database based on the info generated in the backup. If you were to move the data files/log files to a new location you would need to have the file name and specify the new location via the move option with restore.

If you keep the same database name then

Code:
RESTORE DATABASE NorthWind
   FROM DISK = 'c:\Northwind.bak'
and it will restore to it default location




Jaime E. Maccou
Applications Analyst
Database Programmer
 
Old December 5th, 2004, 11:57 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Understand finally, thanks. :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Backup compad ASP.NET 2.0 Basics 1 February 5th, 2008 11:06 AM
backup of database MunishBhatia SQL Server 2005 0 October 5th, 2007 04:20 AM
Backup of Database (C#) meljab BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 31st, 2007 11:45 AM
Backup Database gaurav_jain2403 SQL Server 2000 0 August 3rd, 2006 12:57 AM
Database Backup prakash.wadkar ADO.NET 1 February 22nd, 2005 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.