In an attempt to release log file empty whitespace, we've added the following t-sql statement task as part of a weekly maintenance plan job:
EXEC master.sys.sp_MSforeachdb
'DECLARE @ln varchar(max)
SET @ln=(SELECT name FROM [?].dbo.sysfiles WHERE fileid=2)
USE [?]
BEGIN TRY
DBCC SHRINKFILE (@ln);
END TRY
BEGIN CATCH
END CATCH'
If I 'Start job at step' that single job manually, it seems to run fine and release quite a bit of unused whitespace. We have another domain user that runs the agent service, which has full rights to the log files themselves as well as sysadmin server role and seemingly random user mappings. When checking the job history, it shows that the job completed successfully, but when we view the history of the size of the drive, there is no change at that time. I'm wondering if anyone has any idea about what might be happening here.
Thanks
jt