Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Log file


SQL Log file

Author
Message
premkuttan
premkuttan
Old Hand
Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)

Group: General Forum Members
Points: 321 Visits: 296
I have 2 log files for a database(D and E drive) and i need to delete one which is in E drive. Can i do it directly or do we have some process before doing that.
Jack Vamvas
Jack Vamvas
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 329
Make sure all live transactions are stopped , if there is a transaction ongoing and writing to that log file you will not be able to delete the Log.

Jack Vamvas
sqlserver-dba.com
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
You can't delete any log file that has any portion of the active log regardless of whether there are any currently running transactions or not (stopping transactions won't change that).

Use DBCC LOGINFO to identify which file the active portion of the log is in (VLFs with a status of 2), when all of those are in one file, you can drop the other with an ALTER DATABASE statement.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


menon.satyen
menon.satyen
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 230
Hi,

1. Take backup of your databases.
2. Detach your database after closing all active connections
3. Attach the database using SSMS.
4. Delete the log file that's not required from the db details pane.

This should do it. It worked for me!!
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
menon.satyen (10/30/2012)
Hi,

1. Take backup of your databases.
2. Detach your database after closing all active connections
3. Attach the database using SSMS.
4. Delete the log file that's not required from the db details pane.

This should do it. It worked for me!!


No, no, no!!!

If the log file is deleted (or not attached), SQL could refuse to reattach the DB because either the database was not cleanly shut down or the log file that was 'not required' contained a portion of the active log.

The correct and safe way to remove a log file is the method I gave. Any form of deleting or not attaching a log can potentially destroy the DB entirely requiring a restore from backup.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


George M Parker
George M Parker
SSChasing Mays
SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)

Group: General Forum Members
Points: 660 Visits: 1469
Absolutely a NO, NO! Do not DETACH the database.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
George M Parker (10/30/2012)
Another potential option to use the DBCC SHRINKFILE command with an EMPTYFILE clause to clear out one of the two transaction log files by moving the active portions to the primary log file.


No, it does not.

As Books Online says, shrinkfile with the emptyfile option is for data files. It is used to migrate data pages to other data files in the same filegroup.

Log records cannot be moved by anything. To drop an in-use log, you need to wait until the entire active portion of the log is in the file you want to keep (use DBCC LOGINFO) and then you can simply drop the other file (via alter database or the SSMS GUI), no other commands necessary.

To summarise. Shrinkfile with the emptyfile option is for data files. There is nothing at all that can ever move a log record once it's written into the log file ever.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


George M Parker
George M Parker
SSChasing Mays
SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)

Group: General Forum Members
Points: 660 Visits: 1469
I stand corrected and have removed the inaccurate post. Is it possible that technique worked in SQL 2000? I've confirmed exactly what you stated using a copy of the AdventureWorks2008R2 database and the EMPTYFILE clause has no effect on the transactions that exist in the 3rd file. I've confirmed it both with DBCC LOGINFO.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
George M Parker (10/30/2012)
Is it possible that technique worked in SQL 2000?


No.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


George M Parker
George M Parker
SSChasing Mays
SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)SSChasing Mays (660 reputation)

Group: General Forum Members
Points: 660 Visits: 1469
Thanks Gail.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search