Skip to main content
Nintex Community Menu Bar

Need to reduce K2 log file

  • April 29, 2015
  • 1 reply
  • 54 views

Forum|alt.badge.img+6


 

Symptoms


I need to reduce K2 log file. From past experience I remember this process.

Even though the below is a SQL command I am performing this on a K2 system database, therefore it is important that you verify. Also we want to preserve historical data, so does the below command affect historical data [yes/no]? If not where does the historical data reside?

USE [master]
GO
ALTER DATABASE[K2] SET RECOVERY SIMPLE WITH NO_WAIT
GO
USE [K2]
GO
DBCC SHRINKFILE ('FG_log_1')
GO
ALTER DATABASE K2 SET RECOVERY FULL
GO
 

Diagnoses


I would like to confirm you that shrinking transaction log per command that you mentioned will not affect "historical/archived" records.

You may also need to consider truncating as well. Please see the following:
Database Truncation:
http://technet.microsoft.com/en-us/library/ms189085(v=sql.105).aspx
* Full Recovery Model: truncation happens during transaction log database backup
* Truncation does not reduce the size of a physical log file. Reducing the physical size of a log file requires shrinking the file. For information about shrinking the size of the physical log file, see Shrinking the Transaction Log

 

Resolution

Customer was able to reduce the size of the log file by running the command mentioned in the ticket details.




 

1 reply

OlivierC
Nintex Employee
Forum|alt.badge.img+6
  • Nintex Employee
  • September 1, 2025

Hi All,

You can check with your DBA for confirmation if needed.
You can follow manual shrink advice by these sites but it will need lot of manual steps:
Change SQL from Full Recover to Simple Recovery Model | GoEngineer
https://www.goengineer.com/blog/change-sql-from-full-recover-to-simple-recovery-model
Truncate and shrink log files in SQL Server (rackspace.com)
https://docs.rackspace.com/docs/truncate-and-shrink-log-files-in-sql-server
Shrink Logs for a Database in Single Recovery mode - Microsoft Q&A
https://learn.microsoft.com/en-us/answers/questions/1181664/shrink-logs-for-a-database-in-single-recovery-mode

To be quicker, you can execute this script to get advice statement to do the change from recovery mode simple if needed, and change it again to full after SHRINKDATABASE command, 
This script will provide advice statement for your current DB (please connect on K2 DB):


DECLARE @dbname VARCHAR(100)
DECLARE @dbRecoveryType VARCHAR(100)
DECLARE @dbid INT

DECLARE curDatabases CURSOR FOR
SELECT name, database_id,databases.recovery_model_desc
FROM sys.databases
WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')
AND Name = DB_NAME() --You can remove this to shrink all your database of your SQL server instance.

OPEN curDatabases
FETCH NEXT FROM curDatabases INTO @dbname, @dbid,@dbRecoveryType
WHILE @@FETCH_STATUS = 0 BEGIN
BEGIN
DECLARE @dbfilename VARCHAR(100)
PRINT 'PRINT '''''
PRINT 'PRINT '''''
PRINT 'PRINT ''DB ' + @dbname + ''''
PRINT 'USE MASTER'
PRINT 'GO'

IF (@dbRecoveryType!='SIMPLE') BEGIN
PRINT 'ALTER DATABASE [' + @dbname + '] SET RECOVERY SIMPLE WITH NO_WAIT'
PRINT 'GO'
END

PRINT 'USE [' + @dbname + ']'
PRINT 'GO'

DECLARE curFiles CURSOR FOR
SELECT name
FROM sys.master_files
WHERE type = 1
AND database_id = @dbid

OPEN curFiles
FETCH NEXT FROM curFiles INTO @dbfilename
WHILE @@FETCH_STATUS = 0 BEGIN

PRINT 'DBCC SHRINKFILE ([' + @dbfilename + '], 1)'
PRINT 'GO'

FETCH NEXT FROM curFiles INTO @dbfilename
END
CLOSE curFiles
DEALLOCATE curFiles

PRINT 'PRINT ''SHRINKDATABASE '''
--DBCC SHRINKDATABASE (N'K2')
PRINT 'DBCC SHRINKDATABASE (N''' + @dbname + ''')'

IF (@dbRecoveryType!='SIMPLE') BEGIN
PRINT 'ALTER DATABASE [' + @dbname + '] SET RECOVERY ' + @dbRecoveryType
PRINT 'GO'
END

--If it's not a production environment or the customer don't want to use the functionality of SQL server to get back to DB state to a particular time, you can set finally the recovery model to Simple:
--PRINT 'ALTER DATABASE [' + @dbname + '] SET RECOVERY SIMPLE'
--PRINT 'GO'
PRINT ''
END

FETCH NEXT FROM curDatabases INTO @dbname, @dbid,@dbRecoveryType
END

CLOSE curDatabases
DEALLOCATE curDatabases

 

Kind regards,

Olivier