Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BULK INSERT - Row Terminator

Author  Topic 

rosmiq
Starting Member

5 Posts

Posted - 2010-04-13 : 11:34:57
Hi, Wondering if somebody is able to help me. I am sending a text file via ftp as ASCII and trying to use BULK IMPORT via SQL to import the data into SQL.

I'm struggling with the ROW TERMINATOR. I have opened the file in a Hex Viewer and I see that the line feeds are displayed as 0a 0d. When I use this below script for my BULK INSERT it skips some line feeds.

BULK INSERT temp
FROM 'D:\test\Backup\test.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n')

GO

There is quite a lot of data, instead of having each record on each line, i'm getting some lines with 2 or 3 rows of data onto one line. Column 1 looks correct, it shows the first field of each line, but as I continue through the columns I see that its added another line.

Has anybody come across this before?

Thanks and really appreciate your help on this matter.

rosmiq

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-13 : 11:40:26
try "/r/n" ?
Go to Top of Page

rosmiq
Starting Member

5 Posts

Posted - 2010-04-13 : 11:43:20
Hi, thank you for your response, I tried that, it put it all onto one line.
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-13 : 12:00:53
0a 0d or 0d 0a? 0a= LF, 0d = CR, sounds like you have to reverse your CRLF order from 0A0D to 0D0A

quote:
Originally posted by rosmiq

Hi, thank you for your response, I tried that, it put it all onto one line.

Go to Top of Page

rosmiq
Starting Member

5 Posts

Posted - 2010-04-13 : 12:06:35
Sorry I meant its 0d 0a.
Go to Top of Page
   

- Advertisement -