Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3975098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:38:41+00:00 2026-05-20T04:38:41+00:00

I have data in a simple txt file, a trying to query it (to

  • 0

I have data in a simple txt file, a trying to query it (to 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 the rows but all are NULL because (i think) there is no field terminator and is in UTF-16LE format, in the TXT all the fields are know by the character count, example:

FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6
FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6
FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6
FIELD1FIELD2FIELD3FIELD4FIELD5FIELD6

To make things even worse, the file is in UTF-16LE but I need it in UTF-8 (or change the format within sql 2005) so that openrowset will work

And when I use

SELECT * FROM OPENROWSET ( BULK 'C:\DB\data.txt', SINGLE_NCLOB) AS BinFile  

I get all the data but in a single row 🙁

Thanks in advance

ps: also used sp_addlinkedserver and didnt work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:38:42+00:00Added an answer on May 20, 2026 at 4:38 am

    Thank you guys for your time and brains to try to crack up this problem, finally got it solved with:

    SELECT 
        SUBSTRING(F1, 1, 19) col 1
        ,SUBSTRING(F1, 20, 19) col 2
    FROM OpenRowset(''Microsoft.Jet.OLEDB.4.0'',   
         ''Text;HDR=NO;CharacterSet=unicode;Database='+@path+';
         Extended Properties="Excel 8.0;HDR=Yes;IMEX=1" '',JOURNEY_PLAN#txt);
    

    SUBSTRING to get the data from a file that is not limited by nothing

    CharacterSet=unicode to enable the DB engine to read from a specific character set of the file

    Thanks!!!!!!!!!

    ps: In http://msdn.microsoft.com/en-us/library/bb177651.aspx found the details on the attribute “CharacterSet”, the bad thing is that in the manual for OPENROWSET dosent says a thing about this http://msdn.microsoft.com/en-us/library/ms190312.aspx >:(

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve particular data from a txt file and would like
Hey guys. I'm building a simple blog and have my data returning from my
I have a simple working PHP script to write an HTML table from a
I have a text file with some data in it, and I'm trying to
I am trying to populate a datagrid from a .txt file. I managed to
i have a very simple script that reads out a txt file, puts the
I am trying to display statistics from a simple text file using arrays in
I have a simple data model of two tables, email and recipients, email can
I have only simple data types in method signature of service (such as int,
Let's say I have some simple data y = [[datetime.datetime( 2012,1,1,1,1), 2.1], [datetime.datetime( 2012,1,1,1,2),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.