[dba-SQLServer] Bulk Insert?

Darryl Collins darryl at whittleconsulting.com.au
Thu Jan 9 21:46:56 CST 2014


Hi Folks,

I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version).  Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand.

That said, BULK INSERT should do the job.  I am running  test to check it out and I cannot get it to work at all.

T-SQL is:
'=====================================================================================
BULK INSERT dbo.ProbC_tblProcedureClasses
FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt'
WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n')
'=====================================================================================


The text file is in the target location and contains:
'=====================================================================================
ProcedureClassName,ProcedureClassType
MaterialSource,Mining
Processing,Downstream
'=====================================================================================


Table in SQL Server looks like (PK is SeqID_ProcClass):
'=====================================================================================
Column Name			Data Type	Allow Nulls
ProcedureClassType		nvarchar(32)	Checked
ProcedureClassName		nvarchar(32)	Checked
SeqID_ProcClass		int		Unchecked
SeqID_ProcClassManual	int		Checked
'=====================================================================================


If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server.  However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns
"(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table.

Most curious.  Any idea what I am stuffing up here?

Cheers
Darryl.




More information about the dba-SQLServer mailing list