question

nebester avatar image
nebester asked

Enabling Trace Flag 3042 Does Not Help Skip the Pre-Allocation Space

Enabled trace flag 3042 to skip the pre-allocation space and I ran a 300 GB database backup with compression. However, enabling the trace flag did not help, instead SQL Server pre-allocated the backup file size. The pre-allocation space is causing to generate false disk space alert. Is there another method/configuration that can be used to skip the pre-allocation space? Thanks!

DBCC TRACEOn(3042)

BACKUP DATABASE DatabaseName TO DISK = N'D:\Backup\DatabaseName.bak'

WITH COPY_ONLY, COMPRESSION, STATS = 10

GO

disk-spacedisk-usagespace issue
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnM avatar image
JohnM answered

According to the documentation, that particular trace flag is global only so you can't set it at the session level. You either have to put that in the startup parameters of the service or use this code:

DBCC TRACEON (3402,-1) -- the "-1" sets the TF globally

https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql?view=sql-server-2017

Hope that helps!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.