1

Where are the paths for all the database files stored in SQL? eg: paths for mdf,ldf files for TempDB, and other databases.

I need to find out the file that contains all the paths. I have by mistake changed the TempDB path and I am not able to login into SQL to change it. I need to restore the SQL to previous working state. So I need to know which file to replace inorder to get the correct paths back.

5 Answers 5

1

Try this

Use [your Database Name]
    SELECT * FROM sys.database_files
Sign up to request clarification or add additional context in comments.

Comments

0

You can use sp_helpfile Databasename

Comments

0

i think you can use sys.master_files.

Comments

0

you can access them through the sql management studio (the database properties) do you ask where does it gets the info from ? it's probably in one of the system tables.

enter image description here

Comments

0

use this query:

SELECT 

    mdf.database_id, 

    mdf.name, 

    mdf.physical_name as data_file, 

    ldf.physical_name as log_file, 

    db_size = CAST((mdf.size * 8.0)/1024 AS DECIMAL(8,2)), 

    log_size = CAST((ldf.size * 8.0 / 1024) AS DECIMAL(8,2))

FROM (SELECT * FROM sys.master_files WHERE type_desc = 'ROWS' ) mdf

JOIN (SELECT * FROM sys.master_files WHERE type_desc = 'LOG' ) ldf

ON mdf.database_id = ldf.database_id

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.