Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47

    Question Unanswered: Linking a text file to SQL Server

    Hi all.

    I need to create a Linked Server in SQL 2000 to a text file. Importing the file is not an option. It has to be linked. I tried creating a ODBC link to it but I must be doing something wrong because it didn't work.

    Please help.

    Thanks,
    ODaniels

  2. #2
    Join Date
    Feb 2003
    Location
    India
    Posts
    216
    if you have sucessfully created the linkserver, you can use
    EXEC sp_tables_ex <link server name> to query the tables (csv/txt files) of that link.

    a sample query to retrive rows from a file can look like
    select * from [txtLinkSrv].[d:\folder]..[File1.csv]

    here "txtLinkSrv" is the link server name, "d:\folder" is the folder name that contains the files, "File1.csv" is the name of a csv file.

  3. #3
    Join Date
    Nov 2005
    Location
    Jersey
    Posts
    47
    Thanks upalsen.

    Can this be used with a network path? Or does it have to be local?
    I tried it and I keep getting:

    Server: Msg 7399, Level 16, State 1, Line 1
    OLE DB provider 'MSDASQL' reported an error.
    [OLE/DB provider returned message: [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed]
    [OLE/DB provider returned message: [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed]
    [OLE/DB provider returned message: [Microsoft][ODBC Text Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.]
    OLE DB error trace [OLE/DB Provider 'MSDASQL' IDBInitialize::Initialize returned 0x80004005: ].

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •