Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. bcp command in sql 2008

bcp command in sql 2008

Scheduled Pinned Locked Moved Database
questiondatabasehelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vkEE
    wrote on last edited by
    #1

    Hi, What is wrong with this syntax? I have used this so many times in sql 2005. Kind of new to sql 2008. === bcp "Select * From Webs.About" queryout mytest.dat -T -c === the error message is Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'queryout'.

    N 2 Replies Last reply
    0
    • V vkEE

      Hi, What is wrong with this syntax? I have used this so many times in sql 2005. Kind of new to sql 2008. === bcp "Select * From Webs.About" queryout mytest.dat -T -c === the error message is Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'queryout'.

      N Offline
      N Offline
      NickPace
      wrote on last edited by
      #2

      Not sure if this is it, but try enclosing mytest.dat in quotation marks. Otherwise, it looks like it should work to me.

      -NP Never underestimate the creativity of the end-user.

      1 Reply Last reply
      0
      • V vkEE

        Hi, What is wrong with this syntax? I have used this so many times in sql 2005. Kind of new to sql 2008. === bcp "Select * From Webs.About" queryout mytest.dat -T -c === the error message is Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'queryout'.

        N Offline
        N Offline
        NickPace
        wrote on last edited by
        #3

        Also, make sure you are running the bcp utility from the command prompt. I think if you try running it from a new query window within SMS that is exactly the error you will get. I'm pretty sure the quotation marks I mentioned in my previous post won't help unless the file name has a space in it.

        -NP Never underestimate the creativity of the end-user.

        V 1 Reply Last reply
        0
        • N NickPace

          Also, make sure you are running the bcp utility from the command prompt. I think if you try running it from a new query window within SMS that is exactly the error you will get. I'm pretty sure the quotation marks I mentioned in my previous post won't help unless the file name has a space in it.

          -NP Never underestimate the creativity of the end-user.

          V Offline
          V Offline
          vkEE
          wrote on last edited by
          #4

          How can I ran this through a new query window in SQL? Using xp_cmdshell? Thanks!!

          N 1 Reply Last reply
          0
          • V vkEE

            How can I ran this through a new query window in SQL? Using xp_cmdshell? Thanks!!

            N Offline
            N Offline
            NickPace
            wrote on last edited by
            #5

            Sure, you can use xp_cmdshell to run a bcp command from a query window. You might have to first turn on the ability for SSMS to use a Windows command shell as it is usually off by default. If needed, run the following commands first: EXEC sp_configure 'show advanced options', 1 RECONFIGURE EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE Then run your xp_cmdshell using: EXEC xp_cmdshell '(your bcp command here)' If needed, turn back off the ability to use Windows command shell with: EXEC sp_configure 'xp_cmdshell', 0 RECONFIGURE EXEC sp_configure 'show advanced options', 0 RECONFIGURE

            -NP Never underestimate the creativity of the end-user.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups