Sunday, 6 October 2013

How to restore the database backp file in sql server using script

Restore backup Files using script:


->open the SQL Server 2008 or any other version.
->Click on "New Query"   Write a script  shown below screen shot give database backup file name and specify path of database.





















-> Execute the querry as a result .mdf and .ldf files are displayed.










->go to the "C" drive  select the path  copy it
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

->Select a New Query  and write the script as

RESTORE DATABASE homeseva
FROM DISK = 'D:HomeESeva.bak'
WITH MOVE 'kotireddy' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\kotireddy.mdf',
MOVE 'kotireddy_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\kotireddy_log.ldf'


-> Execute the Query  and the database successfully added. refresh the database.














No comments:

Post a Comment