Issue importing relatively simple .txt file in SQL?

41 views Asked by At

I can't get either of the following two files to upload into Advanced Query Tool. Here's a snapshot of my data:

2,"TEST2",2012-01-01,"TEST","TEST",21111
3,"TEST3",2013-01-01,"TEST","TEST",13111
4,"TEST4",2014-01-01,"TEST","TEST",11411
5,"TEST5",2015-01-01,"TEST","TEST",11151
...

I want to import this file in SQL.

Here's the code I've used so far:

CREATE TABLE #tb_test
(
id integer,
name varchar(10),
dob date,
city char(20),
state char(20),
zip integer
);

insert into #tb_test
values
(1,'TEST','2015-01-01','TEST','TEST',11111);

BULK INSERT #tb_test 
FROM 'H:\tb_test_data.txt'
WITH (FIELDTERMINATOR = ',');

Alternatively, I could try importing a slightly modified file like the following:

2,TEST2,2012-01-01,TEST,TEST,21111
3,TEST3,2013-01-01,TEST,TEST,13111
4,TEST4,2014-01-01,TEST,TEST,11411
5,TEST5,2015-01-01,TEST,TEST,11151
...

But, I'd rather not, because the first file was assigned to me, and the second one seems easier (even though I haven't got that one to work, either!). This is the error message I'm getting:

Error during Prepare 37000(-131)[Sybase][ODBC Driver][Sybase IQ]Syntax error near 'BULK' on line 1 (0.05 secs)
0

There are 0 answers