Wednesday, March 7, 2012

Logical name of the Transaction Log

How can I find out the logical name of the Transaction Log (eg.
Northwind_Log). I'm after some T-SQL that I can use to put the name into a
variable.
Thanks,
Craigselect name,filename from master.dbo.sysaltfiles
http://sqlservercode.blogspot.com/|||-- assuming you have the regular 'ldf' extension:
DECLARE @.logfile_name SYSNAME;
SELECT @.logfile_name = name FROM sysfiles WHERE filename LIKE '%.ldf';
-- SQL Server 2005:
-- SELECT @.logfile_name = name FROM sys.database_files WHERE type=1;
(Others might suggest using the status bits in sysfiles or sysaltfiles, but
I don't like to rely on those because they require specialized knowledge and
bitwise...)
What if you have more than one log file? What "variable" are you going to
put them into?
"Craig HB" <CraigHB@.discussions.microsoft.com> wrote in message
news:11B18021-DFEC-4AEC-8982-5C39B4D96367@.microsoft.com...
> How can I find out the logical name of the Transaction Log (eg.
> Northwind_Log). I'm after some T-SQL that I can use to put the name into a
> variable.
> Thanks,
> Craig

No comments:

Post a Comment