Вопрос

This might be simple but can not find example of selecting LDF file form sys.master_files. I have got the MDF file using

    cmd.CommandText = ("select physical_name from sys.master_files where database_id = DB_ID('" + "mydatabasename" + "')");
Это было полезно?

Решение

The query you are using should actually return all data (MDF) and log (LDF) files for your database.

However, to return only log files, you simply add an extra criteria on the 'type' column. Log files have a type of 1, hence:

cmd.CommandText = ("select physical_name from sys.master_files where type = 1 and database_id = DB_ID('" + "mydatabasename" + "')");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top