Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:09:08+00:00 2026-05-24T20:09:08+00:00

I was looking into the steps of how to Restore Database Backup using SQL

  • 0

I was looking into the steps of how to Restore Database Backup using SQL Script (T-SQL). Here are the steps:

Database YourDB has full backup YourBackUpFile.bak. It can be restored using following two steps:

Step 1: Retrieve the logical file name of the database from the backup.

RESTORE FILELISTONLY
FROM DISK = 'D:BackUpYourBackUpFile.bak'
GO

Step 2: Use the values in the LogicalName column in the following step.

----Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE

----Restore Database
RESTORE DATABASE YourDB
FROM DISK = 'D:BackUpYourBackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'

I am just having problem on how to get the YourMDFLogicalName and YourLDFLogicalName.
Can any one help me with that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:09:10+00:00Added an answer on May 24, 2026 at 8:09 pm
    DECLARE @Table TABLE (LogicalName varchar(128),[PhysicalName] varchar(128), [Type] varchar, [FileGroupName] varchar(128), [Size] varchar(128), 
                [MaxSize] varchar(128), [FileId]varchar(128), [CreateLSN]varchar(128), [DropLSN]varchar(128), [UniqueId]varchar(128), [ReadOnlyLSN]varchar(128), [ReadWriteLSN]varchar(128), 
                [BackupSizeInBytes]varchar(128), [SourceBlockSize]varchar(128), [FileGroupId]varchar(128), [LogGroupGUID]varchar(128), [DifferentialBaseLSN]varchar(128), [DifferentialBaseGUID]varchar(128), [IsReadOnly]varchar(128), [IsPresent]varchar(128), [TDEThumbprint]varchar(128)
    )
    DECLARE @Path varchar(1000)='C:\SomePath\Base.bak'
    DECLARE @LogicalNameData varchar(128),@LogicalNameLog varchar(128)
    INSERT INTO @table
    EXEC('
    RESTORE FILELISTONLY 
       FROM DISK=''' +@Path+ '''
       ')
    
       SET @LogicalNameData=(SELECT LogicalName FROM @Table WHERE Type='D')
       SET @LogicalNameLog=(SELECT LogicalName FROM @Table WHERE Type='L')
    
    SELECT @LogicalNameData,@LogicalNameLog
    

    UPDATE

    According to Microsoft site:

    SQL Server files have two names:

    logical_file_name

    The logical_file_name is the name used to refer to the physical file
    in all Transact-SQL statements. The logical file name must comply with
    the rules for SQL Server identifiers and must be unique among logical
    file names in the database.

    os_file_name

    The os_file_name is the name of the physical file including the
    directory path. It must follow the rules for the operating system file
    names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am looking into developing an iPhone native app using Titanium Developer Since this is
I'm looking into using Visual Studio 2008's built in unit test projects instead of
I am looking to run SQL queries using VBA code in an Excel file.
I'm starting a new project in Wpf, and am now looking into using Prism.
I'm looking into horizontal partitioning for a table that has time-series data in it.
I'm starting a new project in WPF and am now looking into using Prism.
im looking easy steps for convert any html/php template into a very simple wordpress
Looking into selector performance between $('#ID1, #ID2, #ID3') vs $('1X CLASS'). Which is faster?
By looking into the Open JPA website i've found that i can log the
Currently looking into learn new technology and silverlight is on the potential list. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.