Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Bug in Bulk Insert?

$
0
0

So, I'm working with a client today and we discovered some missing records from his file.  I looked into it a bit; the first 5 rows were being truncated.  I thought that is bizarre because the data starts on row 7.  As such, I set up my Bulk Insert like this.

declare @fullpath1 varchar(1000)
select @fullpath1 = '''\\london-sql\FTP\' + convert(varchar, getdate()- @intFlag , 112) + '_SPGT.SPL'''
declare @cmd1 nvarchar(1000)
select @cmd1 = 'bulk insert [dbo].[SPGT_Daily] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 7, ROWTERMINATOR=''0x0a'')'
exec (@cmd1)

So, I open this file, which comes from a Unix system, and I get this.

So, this stock data actually starts on ROW2, not ROW5.  We figured it out pretty quick, and we're all set now.  I'm just not sure why Excel, Wordpad, Notepad, etc, would all show the data starting on ROW7 (field names are in ROW6), and Bulk Insert thinks the data is in ROW2 (field names are in ROW1).

This seems very strange.


Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>