I have a query like this:
use DataIncremental go DECLARE @row_terminator CHAR; SET @row_terminator = CHAR(10); -- or char(10) BEGIN TRAN tran2 DECLARE @stmt NVARCHAR(2000); SET @stmt = ' BULK INSERT accn_adjustments FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201112302112.txt'' WITH ( firstrow=2, FIELDTERMINATOR = ''|'' , ROWS_PER_BATCH=10000 ,ROWTERMINATOR=''' +@row _terminator+''' )' exec sp_executesql @stmt; SET @stmt = ' BULK INSERT accn_adjustments FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201112312112.txt'' WITH ( firstrow=2, FIELDTERMINATOR = ''|'' , ROWS_PER_BATCH=10000 ,ROWTERMINATOR=''' +@row _terminator+''' )' exec sp_executesql @stmt; SET @stmt = ' BULK INSERT accn_adjustments FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201201022101.txt'' WITH ( firstrow=2, FIELDTERMINATOR = ''|'' , ROWS_PER_BATCH=10000 ,ROWTERMINATOR=''' +@row _terminator+''' )' exec sp_executesql @stmt; SET @stmt = ' BULK INSERT accn_adjustments FROM ''C:\Users\agordon\Desktop\incrementaljan2012\accn_adjustments_201201032101.txt'' WITH ( firstrow=2, FIELDTERMINATOR = ''|'' , ROWS_PER_BATCH=10000 ,ROWTERMINATOR=''' +@row _terminator+''' )' exec sp_executesql @stmt;
The reason I put begin tran tran2 is to make sure that if there are errors, I can just do rollback
I ran the code and I got the message "query completed with errors"
SSMS did NOT indicate that some rows were inserted , as they usually do.
When I tried to do rollback tran tran2 , he said this transaction never started
So my question is: were there any rows bound to the database or not?
If not, why did he say that โthe request completed with errorsโ, should he not simply say that the request did not complete due to errors?
source share