I have data in a simple txt file, trying to query it (put it in a table), but when I use
select * from OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=C:\DB\;Extensions=TXT;', 'select * from data.txt ');
I get strings, but all of them are NULL, because (I think) there is no field terminator and is in UTF-16LE format, in TXT all fields are known by the icon, for example:
FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6 FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6 FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6 FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6
To make things worse, the file is in UTF-16LE , but I need it in UTF-8 (or change the format in sql 2005) so openrowset works
And when I use
SELECT * FROM OPENROWSET ( BULK 'C:\DB\data.txt', SINGLE_NCLOB) AS BinFile
I get all the data, but on one line :(
Thank you in advance
ps: also used sp_addlinkedserver and did not work
source share