How to get .ldf file name from .mdf file header using c# .whether it is possible to get the .ldf file name from .mdf file header??if we can get means give code for that....
Asked
Active
Viewed 594 times
0
-
Do you mean from a `.mdf` that is not attached to a server? (If in use on the server, you can use [`sys.database_files`](http://msdn.microsoft.com/en-us/library/ms174397.aspx).) – Richard Dec 11 '14 at 09:16
-
ya the .mdf file not attached to the server.without using script.any c# codes – AishwaryaKasi Dec 11 '14 at 09:17
-
Look at that [link](http://stackoverflow.com/questions/8172763/how-to-read-sql-server-mdf-header-for-log-file-information-programmatically-in-c) please. I hope it will help you. – Orkun Bekar Dec 11 '14 at 09:19
-
ya i already looked that link.the getting after attaching.before attaching how to get ? – AishwaryaKasi Dec 11 '14 at 09:22
-
If you know mdf-file name, than it's simple. To example, `database.mdf` -> `database.ldf`/`database_log.ldf`. – Sinatr Dec 11 '14 at 10:33
-
@Sinatr There is *no requirement* in SQL Server that log files follow that convention. It is merely the default used in SMSS's GUI tools. If files are created programatically, or you override SMSS's defaults, you can use any name you like (even the extension can be different). – Richard Dec 11 '14 at 10:37
-
If it can be anything, then without attaching or knowing that what override does it is an impossible task. Attach first, get log name, detach, do something with log - the only possibility. – Sinatr Dec 11 '14 at 10:48
-
Ya Richatrd is corretct.any other way to get log file name – AishwaryaKasi Dec 11 '14 at 12:12