Pregunta

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" + "')");
¿Fue útil?

Solución

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" + "')");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top