Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to bulk import from txt file into temporary table in SQL Server 2012

I keep getting this error:

Parse error at line: 1, column: 1: Incorrect syntax near 'BULK'.

The following is my text. I am now using a test file with two rows in the correct format so as to rule that out as causing an issue.

create table #tabled1
(
    vehicleid bigint,
    speed decimal(9,6),
    latitude decimal(9,6),
    longitude decimal(9,6),
    direction smallint,
    gpsquality tinyint
)
GO

BULK INSERT #tabled1
   FROM 'C:\Users\michael.mccarthy\documents\test.txt'
   WITH (
      FIELDTERMINATOR = '/t',
      rowtERMINATOR = '/n',
      KEEPNULLS
   );
GO
like image 342
user2772056 Avatar asked Oct 16 '25 14:10

user2772056


1 Answers

user2772056 -- Although you probably resolved this long ago, you are using the incorrect slash. The separator character and the row-terminator should use a backslash "\", not a forward slash "/". Try this--

WITH (
    FIELDTERMINATOR = '\t',
    rowtERMINATOR = '\n',
    KEEPNULLS
);
like image 177
Graeme Avatar answered Oct 18 '25 07:10

Graeme



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!