How to shrink the log file in MS SQL?

beginer
beginer
296 Points
83 Posts

I want to reduce db size. As we using more and more transaction db log file getting big. Can we reduce log file size and so that db size will be reduced.

Views: 559
Total Answered: 2
Total Marked As Answer: 0
Posted On: 10-Feb-2022 21:49

Share:   fb twitter linkedin
Refer following: https://www.mssqltips.com/sqlservertutorial/3311/how-to-shrink-the-transaction-log/ https://docs.microsoft.com/en-us/sql/relational-databases/databases/shrink-a-file?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver15
 - Brian  10-Feb-2022 21:53
Answers
Brian
Brian
Moderator
694 Points
92 Posts
         
Raj
Raj
Member
54 Points
17 Posts
         

Refer to: https://docs.microsoft.com/en-us/sql/relational-databases/databases/shrink-a-file?view=sql-server-ver15#:~:text=Server%20Management%20Studio-,To%20shrink%20a%20data%20or%20log%20file,Shrink%2C%20and%20then%20click%20Files.

To shrink a data or log file

  1. Connect to the Database Engine.
  2. From the Standard bar, click New Query Window.
  3. Execute the following example into the query window. This example uses DBCC SHRINKFILE to shrink the size of a data file named DataFile1 in the UserDB database to 7 MB.
USE UserDB;
GO
DBCC SHRINKFILE (DataFile1, 7);
GO
Posted On: 17-Feb-2022 21:36
 Log In to Chat