none
BCP query

    Question

  • Hi ,

    Am running the below bcp command to transfer data from one to another table.

    it is running succesfuully but the target table has no records.

    exec

    xp_cmdshell 'bcp "select * from table1" queryout "Table2" -N -S localhost -T -E'

    Thursday, July 11, 2013 12:58 PM

Answers

  • BCP only does 1 operation at a time.  You would need to export to a file, and then run BCP again to import into your table.

    However, there is no reason do to this on the same server using BCP, simply run:

    INSERT INTO TABLE2 
    SELECT * FROM TABLE1

    Thursday, July 11, 2013 1:36 PM

All replies

  • The first step to solving your problem is to run your bcp command from a command line.  Does it work as you expect?  Probably not.  Running it using xp_cmdshell will not allow you to debug your problems.  I suggest you look for a file named Table2 to figure out what happened.
    Thursday, July 11, 2013 1:04 PM
  • BCP only does 1 operation at a time.  You would need to export to a file, and then run BCP again to import into your table.

    However, there is no reason do to this on the same server using BCP, simply run:

    INSERT INTO TABLE2 
    SELECT * FROM TABLE1

    Thursday, July 11, 2013 1:36 PM