MS SQL Server Concepts and Programming Question: Download Questions PDF
Where is my database stored on the hard disk in MS SQL Server?
Answer:
If a database is created with simple CREATE DATABASE statement, the server will create two database files on the hard disk to store data and configuration information about that data bases:
* database_name.mdf - SQL Server Database Primary Data File
* database_name_log.ldf - SQL Server Database Transaction Log File
To find out the location of database files, you can query the "sys.database_files" view as shown in this tutorial example:
USE GlobalGuideLineDatabase
GO
SELECT type_desc, physical_name, size
FROM sys.database_files
GO
type_desc physical_name size
ROWS c:Program FilesMicrosoft SQL Server
MSSQL.1MSSQLDATAGlobalGuideLineDatabase.mdf 152
LOG c:Program FilesMicrosoft SQL Server
MSSQL.1MSSQLDATAGlobalGuideLineDatabase_log.LDF 63
Go verify these two files with Windows Explorer.
* database_name.mdf - SQL Server Database Primary Data File
* database_name_log.ldf - SQL Server Database Transaction Log File
To find out the location of database files, you can query the "sys.database_files" view as shown in this tutorial example:
USE GlobalGuideLineDatabase
GO
SELECT type_desc, physical_name, size
FROM sys.database_files
GO
type_desc physical_name size
ROWS c:Program FilesMicrosoft SQL Server
MSSQL.1MSSQLDATAGlobalGuideLineDatabase.mdf 152
LOG c:Program FilesMicrosoft SQL Server
MSSQL.1MSSQLDATAGlobalGuideLineDatabase_log.LDF 63
Go verify these two files with Windows Explorer.
Download MS SQL Server Interview Questions And Answers
PDF
Previous Question | Next Question |
How to get a list all databases on the SQL server? | How to create database with physical files specified in MS SQL Server? |