bcp Challenge

  • can i do a bcp a flat file from unix to sql server 2008 version ?

  • bcp.exe requires a MS operating system....so you can't call bcp.exe from a unix operating system....

    but you can bcp a FILE into or out of a shared directory that exists on a Unix machine ...if it is properly shared ont he network...to or from any SQL server...is that the question?

    you can also of course process the file on the machine that runs bcp.exe...just copying it locally.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • "but you can bcp a FILE into or out of a shared directory that exists on a Unix machine..."

    - Thats what i am looking for. If say I have a file in shared directory in UNIX then can I bcp it into a table in sql server 2008 ? If yes, how ?

  • The same way that you'd do it for any other well formed file except, IIRC, UNIX uses only the "NewLine" character ( \ N) instead of the "Carriage Return/Line Feed" pair which is what BULK INSERT and BCP default to. Obviously, you'd need to make that change for the row terminator.

    Have you ever used BCP or BULK INSERT for anything else, before?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I've done this with the dreaded xp_cmdshell driving putty's ssh and scp, putty is so good at running unix shell scripts and copying files, I've pretty much decided that samba is overkill.

  • patrickmcginnis59 (10/24/2011)


    ...dreaded xp_cmdshell...

    Heh... "dreaded". I love xp_CmdShell. 🙂

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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