This is my first attempt to load data to a sybase table from an external file. Here is my code snippet.
I create the table as below..
IF OBJECT_ID ('dbo.TEST_DATA') IS NOT NULL
DROP TABLE dbo.TEST_DATA
GO
CREATE TABLE dbo.TEST_DATA
(
NAME CHAR (10) NOT NULL
, ID CHAR (4) NULL
)
GO
This is how I try to load the data..
LOAD TABLE dbo.TEST_DATA
(
NAME,ID
)
FROM 'C:\testdata.txt'
DELIMITED BY ','
The data in the file is simple..
xxxxxxx,1111
yyyyy,2222
When I try to load the data, it gives me "Incorrect Syntax near the keyword TABLE" error. I'm not sure what I'm missing.
Becuase you did not specify Product, my guess is you are using Sybase ASE.
The syntax listed above is for Sybase IQ.
To load a table in ASE from a flat file, you should use the
bcp
utility.It would look something like this:
The
-c
specifies that the file is plaintext, and-t ,
specifies the column delimiter (default is tab).More information can be found in the bcp section of the Sybase ASE Utility Guide It's from the ASE 15.5 docs, but the syntax is the same for most versions 12.0 and newer.