sql-serverdatabase-administrationsystem-tables

Why there is a difference between sp_helpfile vs sys.master_files?


Hi while restoring database using restore command in sql server to specific drive, after executing sp_helpfile its showing incorrect file path, however sys.master_files showing right file path ? why sp_helpfile showing inaccurate path? can somebody please help me to understand this?


Solution

  • Too long to comment.

    I suspect you aren't connected to the correct database when you run sp_helpfile. If you query sys.master_files it will return the same thing regardless of what database you are connected to. However, sp_helpfile used the default connection if you don't specify a file name. Thus, if you are connected to [master] it will return results for the files of this database.