deleting a log file permanently

In SQL 2012 I'm trying to delete a log file (both physically and logically). There are two log files and one of them is unnecessary. When I click 'remove' in SSMS it will delete the log file, but then when I go back under database properties it's still showing up even though the file has been physically removed from the OS. I'm wondering what steps I can take to get rid of the file permanently?

Thanks,

phil

July 6th, 2015 4:25pm

Do like in this example:

DBCC SHRINKFILE (Northgale_log2, EMPTYFILE )
go
ALTER DATABASE Northgale REMOVE FILE Northgale_log2

You may have to run CHECKPOINT a few times for it to work. (This is the end of a database population script that I have. The ALTER statment always fails when I run the script, but when I rerun the command manually, it succeeds.)

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 6:40pm

To remove one logfile detach the DB and move the file which is not required to some other drive and attach the DB, if any issues please post the same.

Using T-SQL

USE master;
GO
ALTER DATABASE AdventureWorks2012
REMOVE FILE test1dat4;
GO

July 6th, 2015 10:49pm

1)USE master; GO ALTER DATABASE DBNAME REMOVE FILE Logfile;

go

2)sp_helpdb dbname

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 11:01pm

The method suggested by Erland is most appropriate. You should not use GUI to remove files you MUST always use TSQL to perform such actions it is more reliable and it would give you error if any. GUI many a times does not gives error and it seems like operation has completed successfully
July 7th, 2015 12:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics