I have a simple stored procedure that will truncate the log file but I now need to make this dynamic so that this proc can be run with any DB name. I know you can look up the logical filename in sysfiles but I'm not too sure how to write this procedure so that it will simply truncate the log file of the currently selected DB.
This is what I have so far which as you can see is hardcoded:
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS OFF
CREATE PROCEDURE TruncateLog AS
BACKUP LOG [FICaches] with TRUNCATE_ONLY
DBCC SHRINKFILE (FICaches_log, 50)
SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON
Mainly because I call the tuncate log stored proc from perl scripts that are used within our software and the log file is truncated on an ad hoc basis after some specific updates on the DB have run from the perl scripts.