Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: Easy BCP question ;)

    Hey all,

    A nice easy BCP question for y'all...
    I'm currently running:
    Code:
    DECLARE @sql varchar(2000)
    
    SET @sql = 'BCP master..sysobjects OUT C:\sysobjects.csv -c -t, -T -S' + @@ServerName
    
    EXEC master..xp_cmdshell @sql
    Which works fine!
    But how on earth do I save it to my local PC?
    May sound silly, but this is one of my first adventures into BCP and I'd rather not "pollute" the server with my test files!

    Thankyall!
    George
    Home | Blog

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Maybe if you ran the bcp command from your local command line? There is no real reason you need xp_cmdshell.

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    indeed. another possibility is to write the file to a share (but then you are susceptible to network glitches of course)

    BCP master..sysobjects OUT \\SOME_OTHER_SERVER\sysobjects.csv ...

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by MCrowley
    There is no real reason you need xp_cmdshell.

    Can I have a hit off of that?

    This is the way I always do this

    Unless I'm having a problem, then I do command line to get a better error message

    George, what do you mean by pollute?

    You can use xp_... to delete the damn files as well
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The guys downstairs get antsy when I leave csv files on the server that I maintain.
    They polluted one of our production servers with an image of a laptop once (15Gb when we had 15.1Gb free!) and ever since then are very quick to point out when I leave a 0.5Mb csv on a production server.

    anyhow, enough office politics.
    I wouldn't know what to do from the command line - I tried running the above straight in (ok, I had 11 seconds left of my working day - I wasn't thorough (or bothered)) and I just got a "BCP is not a recognized function" (or similar).

    Anyhow, it's pretty much a non-issue I suppose because I just have to remember to delete them, or as Brett suggested, I will go digging for the xp_.. to delete the bugger when I have some play time.

    Thanks all
    George
    Home | Blog

  6. #6
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    oh never mind
    Last edited by Thrasymachus; 09-13-07 at 16:23.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by georgev
    The guys downstairs get antsy when I leave csv files on the server that I maintain.
    They polluted one of our production servers with an image of a laptop once (15Gb when we had 15.1Gb free!) and ever since then are very quick to point out when I leave a 0.5Mb csv on a production server.
    Scrubs

    This message is too short
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by georgev
    Anyhow, it's pretty much a non-issue I suppose because I just have to remember to delete them, or as Brett suggested, I will go digging for the xp_.. to delete the bugger when I have some play time.
    It's called DOS youngster and the command is DEL. Kids today and their GUIs.

    Quote Originally Posted by georgev
    anyhow, enough office politics.
    just remember one thing...

    Quote Originally Posted by conan
    crush your enemies, drive them before you, and hear the lamentations of their women
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sean, I learned a lot in DOS... But it's been far too long since I've had to use it!
    Nothing would sodding run through the GUI on my Windows 3.0 PC

    Dir /w
    George
    Home | Blog

Posting Permissions

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