Microsoft KB Archive/281409

= FIX: BULK INSERT Fails with BATCHSIZE=1, FIRE_TRIGGERS, and TABLOCK =

Article ID: 281409

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q281409



BUG #: 351227 (SHILOH_bugs)



SYMPTOMS
Running a BULK INSERT statement with the following parameters may cause an access violation:

BATCHSIZE = 1, FIRE_TRIGGERS, TABLOCK

If the TABLOCK parameter is omitted but the table option Table lock on bulk load is set to true, the access violation still occurs.

Running the statement in the SQL Server Query Analyzer gives the following result:

ODBC: Msg 0, Level 19, State SqlDumpExceptionHandler: Process 51 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process. Server: Msg 1203, Level 20, State 1, Procedure t_ins, Line 5 Process ID 51 attempting to unlock unowned resource TAB: 10:386100416 []. ODBC: Msg 0, Level 16, State 1 Communication link failure ODBC: Msg 0, Level 16, State 1 Communication link failure



RESOLUTION
To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack



WORKAROUND
To work around this problem, use any one of these methods:
 * Do not use the TABLOCK option with the BULK INSERT statement.
 * Do not set the table option Table lock on bulk load to true.
 * If you must use a table lock, specify BATCHSIZE to be something other than 1.



STATUS
Microsoft has confirmed that this is a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.



MORE INFORMATION
To reproduce the problem, run the following statements in the SQL Server Query Analyzer: if object_id('t1') is not null drop table t1 if object_id('t2') is not null drop table t2 if object_id('t_ins') is not null drop trigger t_ins set nocount on go

create table t1 (id int) go

create table t2(id int) go

insert into t1 values (1) go

declare @query nvarchar(4000) select @query = replace('bcp (database name).dbo.t1 out \t.bcp -n -T', '(database name)', db_name) exec master..xp_cmdshell @query go

create trigger t_ins on t1 for insert as begin set nocount on  insert into t2 (id) values (1) end go

bulk insert t1 from '\t.bcp' with (fire_triggers, datafiletype='native', tablock, batchsize=1) go

select * from t1 go

select * from t2 go

Additional query words: 1203 error

Keywords: kbbug kbfix kbsqlserv2000sp1fix KB281409

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.