BCP with 2012 secondary replicas

  • Hi,

    I've been trying to re-direct some BCP export processes to a secondary read-only SQL Server 2012 (11.0.5058) replica, but can't get it to redirect.

    Below is an example of a test I've been running:

    bcp "select * from <Table_Name>" queryout <File_Name>.csv -t \t -r ^|~^| -c -T –S <Listener> -e -K ReadOnly

    The BCP runs ok, but on the primary replica not the read only secondary.

    I've tested ApplicationIntent=ReadOnly with other connections and these are being re-directed, so its working for other processes, just not BCP.

    Is there something I'm missing?

    cheers

    Roop

  • can't see the database name specified

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Hi,

    Yes, sorry, I didn't make that clear, the database name is in the script:

    Select * from <db>.<schema>.<table>

    Cheers

    Roop

  • rupert.hirst (11/18/2014)


    Hi,

    Yes, sorry, I didn't make that clear, the database name is in the script:

    Select * from <db>.<schema>.<table>

    Cheers

    Roop

    Ok, let me expand a little, i can't see the database name in the BCP command line.

    You've specified the listener and readonly intent but you haven't specified the database name

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • rupert.hirst (11/18/2014)


    Hi,

    Yes, sorry, I didn't make that clear, the database name is in the script:

    Select * from <db>.<schema>.<table>

    Cheers

    Roop

    Ok, let me expand a little, i can't see the database name in the BCP command line.

    You've specified the listener and readonly intent but you haven't specified the database name

    bcp "select * from <Table_Name>" queryout <File_Name>.csv -t \t -r ^|~^| -c -T –S <Listener> -d thedbname -e -K ReadOnly

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Aha,

    Ok, I'm with you, yes I was missing the specific -d <dbname> parameter, and with this added, it looks to work.

    With the -d parameter my connection is to the specific HA DB rather than master....

    Many thanks Perry....

  • rupert.hirst (11/18/2014)


    Aha,

    Ok, I'm with you, yes I was missing the specific -d <dbname> parameter, and with this added, it looks to work.

    With the -d parameter my connection is to the specific HA DB rather than master....

    Many thanks Perry....

    😎 😉

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 7 posts - 1 through 6 (of 6 total)

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