Script to export table under bash executable

  • Hello

    I am new to SQL

    I have bee using R for a long time and I am attempting to write bash scripts in Python to automate some workflow

    I can write the SQL queries easily enough, but to my understanding a BASH script cannot use a GUI; thus a data extract needs to be exported with script. However SQL Server Studio 2012 does not intuitively do this.

    What is the easiest way to do this?

    I am unsure how SQLCMD or BCP are to be integrated into SQL and my other attempots have failed; see:

    USE PRODUCTION.ENV

    INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 2010;Database=C:\out.csv;',

    'SELECT * FROM') select * from CUSTOMERS

    The error I am getting is:

    Msg 7308, Level 16, State 1, Line 2

    OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.

    I have no idea what any of this means and stackoverflow is not very clear as to how to do this

    Thanks for your assistance in advance

    Steve

  • To use queries such as this you need to enable Ad Hoc Distributed Queries.

    This does have certain security implications, so here's the link to MSDN, which explains about it, and how to enable it, rather than myself.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

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

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