October 14, 2009 at 11:37 am
when importing a CSV file ino SQL using a stored procedure with the following code:
SELECT *
INTO theImportTable
FROM
OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DEFAULTDIR=D:\;Extensions=CSV;',
'SELECT * FROM CSVFile.csv')
It makes the connection and reads the file but does not parse any of the fields. The result set is one column instead of 10 and the contents of the one column is all NULL values.
I have been searching Google trying to find a similiar issue and was unable to see any examples of the problem.
Any help would be greatly appreciated.
October 14, 2009 at 11:41 am
Hi,
Try to create FORMAT file (using bcp) or use BULK INSERT and provide proper FIELDTERMINATOR parameter.
Regards
Piotr
...and your only reply is slàinte mhath
October 14, 2009 at 11:45 am
I tried that first, but I can not seem to get BCP to work. When I type in the command the machine just flashes and doesn't appear to do anything. The format file I put in the command to create doesn't exist.
Since it is a command line exe I use the run options off of windows to execute the BCP command. I do not know what I am doing wrong and why I can not get the BCP command to bring me back any errors.
October 14, 2009 at 1:14 pm
I think that you have to familiarize with parameters of BCP. You have to run it from command line, so first run cmd.exe and then type bcp. It will display list of parameters.
Regards
Piotr
...and your only reply is slàinte mhath
October 15, 2009 at 3:25 pm
Thank you for the responses I got the BCP process to work
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply