SQL SSMS on development - clear ldf files












0















Working on building a big SQL Server database, I noticed my C drive is running out of space when running heavy SQL queries.



The following folder size is over 150GB, log.ldf files reach over 50GB.



C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERMSSQLDATA


The DB is still under development and I don't need any transaction logs or stuff like that.



How can I safely clear those log files?










share|improve this question















migrated from superuser.com Jan 3 at 15:59


This question came from our site for computer enthusiasts and power users.
















  • Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

    – spikey_richie
    Jan 3 at 16:07











  • thanks a lot! but i curious why it 'dirty' way?

    – r.tom
    Jan 3 at 16:26











  • Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

    – spikey_richie
    Jan 4 at 11:02
















0















Working on building a big SQL Server database, I noticed my C drive is running out of space when running heavy SQL queries.



The following folder size is over 150GB, log.ldf files reach over 50GB.



C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERMSSQLDATA


The DB is still under development and I don't need any transaction logs or stuff like that.



How can I safely clear those log files?










share|improve this question















migrated from superuser.com Jan 3 at 15:59


This question came from our site for computer enthusiasts and power users.
















  • Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

    – spikey_richie
    Jan 3 at 16:07











  • thanks a lot! but i curious why it 'dirty' way?

    – r.tom
    Jan 3 at 16:26











  • Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

    – spikey_richie
    Jan 4 at 11:02














0












0








0








Working on building a big SQL Server database, I noticed my C drive is running out of space when running heavy SQL queries.



The following folder size is over 150GB, log.ldf files reach over 50GB.



C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERMSSQLDATA


The DB is still under development and I don't need any transaction logs or stuff like that.



How can I safely clear those log files?










share|improve this question
















Working on building a big SQL Server database, I noticed my C drive is running out of space when running heavy SQL queries.



The following folder size is over 150GB, log.ldf files reach over 50GB.



C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERMSSQLDATA


The DB is still under development and I don't need any transaction logs or stuff like that.



How can I safely clear those log files?







sql-server sql database-administration ssms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 10:01









Law29

3,0821826




3,0821826










asked Jan 3 at 15:41









r.tomr.tom

1




1




migrated from superuser.com Jan 3 at 15:59


This question came from our site for computer enthusiasts and power users.






migrated from superuser.com Jan 3 at 15:59


This question came from our site for computer enthusiasts and power users.















  • Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

    – spikey_richie
    Jan 3 at 16:07











  • thanks a lot! but i curious why it 'dirty' way?

    – r.tom
    Jan 3 at 16:26











  • Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

    – spikey_richie
    Jan 4 at 11:02



















  • Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

    – spikey_richie
    Jan 3 at 16:07











  • thanks a lot! but i curious why it 'dirty' way?

    – r.tom
    Jan 3 at 16:26











  • Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

    – spikey_richie
    Jan 4 at 11:02

















Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

– spikey_richie
Jan 3 at 16:07





Quick and dirty way is to right-click the database in SSMS, Tasks > Shrink > Files. Select 'File Type' of Log and ensure the 'Release Unused Space' radio button is set. Click OK and watch the log shrink.

– spikey_richie
Jan 3 at 16:07













thanks a lot! but i curious why it 'dirty' way?

– r.tom
Jan 3 at 16:26





thanks a lot! but i curious why it 'dirty' way?

– r.tom
Jan 3 at 16:26













Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

– spikey_richie
Jan 4 at 11:02





Because it assumes the log file is effectively empty. It also doesn't deal with a log file that has data at either end of the file on disk, in which case you'd want to use Reorganize instead of Release

– spikey_richie
Jan 4 at 11:02










1 Answer
1






active

oldest

votes


















1














You can truncate the log file by issuing the following code block from SSMS:



-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO


You can check the full documentation at this MS DOCS page



There's is more information regarding this topic but I'm trying to address your question with the details you're providing. Hope it helps!






share|improve this answer


























  • What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

    – Katherine Villyard
    Jan 3 at 18:13













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f947486%2fsql-ssms-on-development-clear-ldf-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can truncate the log file by issuing the following code block from SSMS:



-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO


You can check the full documentation at this MS DOCS page



There's is more information regarding this topic but I'm trying to address your question with the details you're providing. Hope it helps!






share|improve this answer


























  • What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

    – Katherine Villyard
    Jan 3 at 18:13


















1














You can truncate the log file by issuing the following code block from SSMS:



-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO


You can check the full documentation at this MS DOCS page



There's is more information regarding this topic but I'm trying to address your question with the details you're providing. Hope it helps!






share|improve this answer


























  • What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

    – Katherine Villyard
    Jan 3 at 18:13
















1












1








1







You can truncate the log file by issuing the following code block from SSMS:



-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO


You can check the full documentation at this MS DOCS page



There's is more information regarding this topic but I'm trying to address your question with the details you're providing. Hope it helps!






share|improve this answer















You can truncate the log file by issuing the following code block from SSMS:



-- Truncate the log by changing the database recovery model to SIMPLE.  
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO


You can check the full documentation at this MS DOCS page



There's is more information regarding this topic but I'm trying to address your question with the details you're providing. Hope it helps!







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 19:00

























answered Jan 3 at 16:07









Humberto CastellonHumberto Castellon

7281216




7281216













  • What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

    – Katherine Villyard
    Jan 3 at 18:13





















  • What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

    – Katherine Villyard
    Jan 3 at 18:13



















What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

– Katherine Villyard
Jan 3 at 18:13







What Humberto said. Also, if you're using the database for development and "don't need your transaction log," leave it on simple recovery. This article on simple vs. full recovery might help.

– Katherine Villyard
Jan 3 at 18:13




















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f947486%2fsql-ssms-on-development-clear-ldf-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido