When doing some re-indexing on a server, I had to create an additional log file so that the disk drive would not fill up and stop the database / re-index operation.
Subsequent to doing my re-index, no matter how many times I attempted to do a dbcc shrinkfile with the emptyfile option, the file would not delete.
The file ‘Database_Log_File’ cannot be removed because it is not empty.
-- EMPTY TRANSACTION LOG FILE
-- TO CLEAR OUT TRANSACTION LOG FILE -- PERFORM A TRANSACTION LOG BACKUP - Standard SQL Backup
BACKUP LOG [myDatabase] TO DISK = '\\myBackupShare\myDatabase_yyyymmdd.trn',INIT, PASSWORD= 'myPasword';
-- TO CLEAR OUT TRANSACTION LOG FILE -- PERFORM A TRANSACTION LOG BACKUP - Red Gate
DECLARE @exitcode int
DECLARE @sqlerrorcode int
EXEC MASTER..sqlbackup N'-SQL "BACKUP LOG [myDatabase]
TO DISK = ''\\myBackupShare\''
WITH NAME = '''', DESCRIPTION = '''',
INIT, PASSWORD = ''myPasword''
, MAXDATABLOCK = 65536,KEYSIZE = 256, COMPRESSION = 1, THREADS = 1"'
, @exitcode OUTPUT, @sqlerrorcode OUTPUT
-- REMOVE TRANSACTION LOG FILE
ALTER DATABASE [myDatabase] REMOVE FILE [myDatabase_LOG2]