Restore Backup SQL Server with Query

First write query as given :
  
 restore filelistonly from disk='D:\demo26022014.bak' 
  
 Note:where  D:\demo26022014.bak is location of your datbasebackup file
  
 Run above query after that will will get 2 rows as following:
  
 salesMS C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\DB_9AA645_dtrackdemo_data.mdf
 
 salesMS_log C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\DB_9AA645_dtrackdemo_log.ldf
  
 Now, write a query:
  
 RESTORE DATABASE ASHOKDB
 FROM disk='D:\demo26022014.bak'
 With Move 'salesMS'   To 
  'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\ASHOKDB.mdf',
 Move  'salesMS_log'  To
 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\ASHOKDB.ldf'
 
 ASHOKDB
 

 Database name you can write as your new database name
  
 just copy pest root path that you have after running  first query
  
 and just make small change in last
  
 DATA\DB_9AA645_dtrackdemo_data.mdf  - Replace with DATA\ASHOKDB.mdf
 DATA\DB_9AA645_dtrackdemo_log.ldf  - Replace with  DATA\ASHOKDB.ldf'
  
 And run bellow code:
 
 
 RESTORE DATABASE ASHOKDB
 FROM disk='D:\demo26022014.bak'
 
 With Move 'salesMS' To
 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\ASHOKDB.mdf',
 Move 'salesMS_log' To
 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\ASHOKDB.ldf'
Ebook Download
View all
Learn
View all