Sunday, February 19, 2012

Accessing the Log File Physical File Name and Path

I am new to SMO and VB.NET and I need to access the transaction log's physical file name and path so that I can correctly relocate it when it is restored on a different.

What I would like to do is display the database and log's physical file and path names in some type of data control for selection by a user during a restore operation.

I have been able to do this for the database but can't seem to get it to work for the log file. How do I find the log file's physical file name and path using SMO? I can't seem to be able to relate the logfile collection and class to specific databases.

Thanks for your help!

Database.LogFiles property gives you a collection of LogFile object, each of which represents a log file on the database. You can access the location and name of the log file using LogFile.FileName and LogFile.Name properties respectively. Refer BOL for more details.

Thanks,
Kuntal

|||Thanks, I've got it working now. I don't know what it was, but something you said sent me in the right direction. I already knew about Database.Logfiles but couldn't put it together until I read your post.

No comments:

Post a Comment