How to use OPENDATASOURCE to read in text files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sepgiv
    New Member
    • Apr 2010
    • 3

    #1

    How to use OPENDATASOURCE to read in text files

    I am using OPENDATASOURCE to read data from files
    when the file extension is txt ,retrieve is successful
    Code:
    select * 
    from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
    'Data Source="c:\files";Extended properties="Text;hdr=no"')...clients#txt
    but when the file name type is not txt ,retrieve fails
    Code:
    select * 
    from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
    'Data Source="c:\files";Extended properties="Text;hdr=no"')...clients#aln
    is it mandatory to use only txt extension ?

    thank you
    Last edited by Frinavale; Apr 27 '10, 03:27 PM. Reason: Added code tags.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    No, it all depends on the type of file you are reading.Read the full BOL article about OpenDataSource.

    Happy Coding!!!

    ~~ CK

    Comment

    • sepgiv
      New Member
      • Apr 2010
      • 3

      #3
      both files are the identical .only the extenision name is differant .
      i noticed that if the file name is clients#aln the select fails , but if i change the file name to is clients#txt then the select works fine .
      by the way where can i find the article you are talking about ?

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        You can find it here...

        Happy Coding!!!

        ~~ CK

        Comment

        • sepgiv
          New Member
          • Apr 2010
          • 3

          #5
          I have already read this article , it does not explain my problem and does not explain how to solve it . can you tell me what to do ?
          thank you

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            I have tried using other extension before with no problem. But mostly are "CSV, ASC" that usually pertains to text file. Also, ff the pound sign is part of your filename, try using another an underscore.

            Good Luck!!!

            ~~ CK

            Comment

            Working...