SQL Server - SQL Server Database Backup Restore through query

Asked By MILAN SHAH
06-Aug-09 05:00 AM
Hello Friends,

I need to restore my back file of SQL Server database with different name.
means i have one database with name "SVC.mdf" i have taken back of that whole database
with name "SVCBK.bak" and stored at some place in my hard drive
i want to restore my back file "SVCBK.bak" to SQL Server Using Query.


restoring the database  restoring the database

06-Aug-09 05:22 AM

Restoring database backup through query:

----Make Database to single user Mode
ALTER DATABASE
SVCBK.bak
SET SINGLE_USER
WITH
ROLLBACK
IMMEDIATE

----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:\SVCBK.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:\SVCBK.mdf',
MOVE 'YourLDFLogicalName' TO 'D:\SVCBK.LOG'

/*If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user.*/
ALTER DATABASE YourDB SET MULTI_USER
GO

Thanks,

re  re

06-Aug-09 05:57 AM

u can take back up by query as follows

 

Transact-SQL commands executed from SQL Query Analyzer. An example of such a command is illustrated below.

BACKUP DATABASE northwind 
TO DISK = 'd:\backups\northwind\nwind.bak'
using Transact-SQL commands. Assuming that the database backup file name is c:\backups\northwind\nwind.bak, the following command will restore the database to nwind_new:
RESTORE DATABASE nwind_new FROM DISK = 'c:\backups\northwind\nwind.bak'
WITH
MOVE 'northwind' TO 'd:\Program Files\Microsoft SQL 
Server\Data\nwind_new.mdf'
MOVE 'northwind_log' TO 'd:\Program Files\Microsoft SQL
Server\Data\nwind_new_log.ldf'
http://technet.microsoft.com/en-us/library/cc966495.aspx

RE  RE

06-Aug-09 07:26 AM
Hi

You can write query and execute in  sql server


ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE

RESTORE DATABASE YourDB
FROM DISK = 'D:SVCBK.bak'
WITH MOVE 'SVCBK' TO 'D:SVCBK.mdf',
MOVE 'SVCBK' TO 'D:SVCBK.mdf'


Thank you

Create New Account
help
MS SQL ? SQL Server I've always thought that SQL was associated with databases? I have the following on my machine. . . Microsoft SQL Server 2005 Microsoft SQL Server Native Client Microsoft SQL Server Setup Support Files (English) Microsoft SQL Server VSS
MSDE on Windows 2003 R2 box, new DL385G6 - Install Fails during SQL Services SQL Server I have been finding that I am having trouble with the Crystal Reports Server XI installation failing when it is dealing with SQL. So, as a thought and in case there was something wrong with my SQL portion of the isntall. I thought ok, I will try installing the actual MSDE application direct from Microsoft. So, I downloaded the MSDE for SQL 2000 (which is msde2000a.exe), set my switches and off to the races. It quit
Can't get Sql Server 2005 to install and start SQL Server I am trying to install Sql Server 2005 to my Laptop and it seems to install but it can't start the Product : SQLXML4 Product Version : 9.00.1399.06 Install : Successful Log File : C: \ Program Files \ Microsoft SQL Server \ 90 \ Setup Bootstrap \ LOG \ Files \ SQLSetup0006_CATH-SATELLITE_SQLXML4_1.log - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Machine : CATH-SATELLITE Product : SQL Server
Any ideas? New to SQL & installing ACT - why does the install fail? SQL Server Microsoft SQL Server 2005 9.00.3042.00 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = OS Version : Microsoft Windows XP Home Edition Service Pack 3 (Build 2600) Time : Sat Dec 26 22:38:29 2009 Machine : D89YH1G1 Product : Microsoft SQL Server Setup Support Files (English) Product Version : 9.00.3042.00 Install : Successful Log
SQL Express: Failed Reinstall SQL Server Dear Setup Experts: I am trying to reinstall SQL Express after playing with it some. I uninstalled it, and now, it refuses to reinstall in the face. Any ideas what this log file means and how I can get SQL Express installed? I really do not want to have to reinstall my whole system. * ** ** Start of Log File Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup. Exit code (Decimal): -2068643839 Exit facility code: 1203