Showing posts with label transaction. Show all posts
Showing posts with label transaction. Show all posts

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

Monday, February 20, 2012

Logging output in a transaction

We have a publish job that we are trying to automate, the problem is getting the output back to the app. or a file. Originally we had print statements, this worked great when we manually ran the proc in QA and could capture the output, now that we are automating it from an application I am not sure how to capture these Print statements - ideally I would like to find this out.

The App. is doing a Try-Catch block so using something like isql.exe will not do the trick otherwise that is the route we would go.

I tried logging everyting to a table but those inserts get rolled back with XACT_ABORT. What about the xp proc that logs it to the event log? Thought of that but that would make a real mess of the event log with all of our status messages.

Now we are considering using xp_cmdshell that calls a batch file to output our status text, is this my best option? I would prefer to capture all of the print statements so if anyone knows how to do this that would be preferable!

Thanks!:bump:

wrong forum? Should I try in an App Dev forum, perhaps?