OPENROWSET / working with External Tables

  • :I need to supply to a 3rd party a store procedure to execute and to create an Excel file based on a SELECT statement of mine.

    To do so, I start my store procedure as follow:

    declare @sql nvarchar(4000)

    -- set up linked server

    SET @sql='EXEC sp_addlinkedserver MyExcel,

    ''Jet 4.0'',

    ''Microsoft.Jet.OLEDB.4.0'',

    '''+CASE WHEN RIGHT(RTRIM(@file_path),1)!='\' THEN RTRIM(@file_path)+'\'

    ELSE RTRIM(@file_path)

    END + @file_name+''',

    NULL,

    ''Excel 5.0;''';

    EXEC sp_executesql @sql;

    --Set up login mappings (just ADMIN ).

    SET @sql = 'EXEC sp_addlinkedsrvlogin MyExcel, FALSE, NULL, Admin, NULL';

    exec sp_executesql @sql;

    Two questions, please:

    1. I had an Office2003 installed on my local machine, and all was OK. upgraded to Office2007 and I have started to fail on 'Microsoft.Jet.OLEDB.4.0' messages in the database (SQL2005).

    I have asked to downgrade me back to Office2003 and MAGIC - it works fine again! What should I do to be able to run it with Office2007?

    2. I have seen somewhere, but can't recall when, a trick to move / copy External Files using EXEC sp_something_i_dont_rememeber. I want to move and copy my Excel files as a part of my main store procedure.

    Any ideas how, please?

    MANY THX As USUAL

  • PLEASE! PLEASE! PLEASE!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply