Today I stumbled across what is possibly the most comprehensive, useful page on the net about bulk loading data into SQL Server 2008. While it is packed with useful information, one of the pearls is about trace flag 610.
In a nutshell, trace flag 610 instructs the server to minimally log all operations that can be minimally logged. In practical terms, this means that MERGE and INSERT operations will minimally log new page allocations. Without trace flag 610, these operations are fully logged. The link (above) goes into great detail about the usage of trace flag 610, so I'll simply summarize as follows:
DBCC TRACEON (610); -- enables trace flag 610
MERGE INTO xxx USING yyy ON -- do minimally logged upsert
DBCC TRACEOFF(610); -- restore normal mode.
Note that setting trace flag 610 will affect all connections to the server until it is reset, so avoid using it on main OLTP servers. For a usable T-SQL MERGE example, see Sunil's blog posting.
Comments