In Books Online (BOL), Example F of the xp_sqltrace entry contains a table similar to SQL Trace. Unfortunately, the example table contains two serious bugs you need to know about. The BOL SQL Trace Application column is defined as NOT NULL, which causes your bcp operation to fail if the client doesn't provide this information in its ODBC or DB-Lib connection string.

The second problem is with the Hostprocess column, which BOL defines as INT. Windows NT's hostprocess is a 32-bit number that can exceed the defined range for INT of ±2,147,483,648. Hostprocess usually falls within SQL's INT range, but it could exceed the maximum value, which would also cause bcp to fail. Discovering these bugs wasn't easy, so don't forget to fix the Application and Hostprocess datatypes if you copy the SQL Trace table directly from BOL. If you're working with large trace files, check out my article "Seven Tips for Speeding Large Data Loads with Bulk Copy Program," February 1997, for information about tuning bcp.