I am running a long query, and using trace flag 2312 in SQL Server.
I've noted that
- when using this trace flag my query returns all results at once, after roughly 20 minutes.
- when not using this trace flag my query returns rows continuously, finishing after roughly 30 minutes.
This is reflected when I make this call to IDBCommand.ExecuteReader(), with the trace flag this function completes after 20 minutes, without the trace flag the function completes immediately.
My problem is I get the expected trace flag behaviour if I manually add it as an option to my query like Select * from table option (querytraceon 2312). However, I tried to set the trace flag for the db server globally DBCC traceon(2312, -1) and confirmed that the flag was active using DBCC tracestatus(). However, when I then try to create my reader using the query Select * from table, the ExecuteReader() call finishes immediately, and I can tell that this trace flag is somehow not being picked up.