BCP Question

  • I'm having problems figuring a couple details out.

    I'm needing to export a table from SQL [ADCA7-11-2] and I need to include field names as a header row, as well as have the fields comma delimited.

    Is this something BCP can do easily or is everything basically tab delimited and such and due to this I should really look into using DTS to export all of my tables that need to be exported?

    Thanks

     

  • You should be able to do that in BCP With field terminator switch, you can use anything from '(tics) to |(Pipes) whatever

    usage: bcp {dbtable | query} {in | out | queryout | format} datafile

      [-m maxerrors]            [-f formatfile]          [-e errfile]

      [-F firstrow]             [-L lastrow]             [-b batchsize]

      [-n native type]          [-c character type]      [-w wide character type]

      [-N keep non-text native] [-V file format version] [-q quoted identifier]

      [-C code page specifier]  [-t field terminator]    [-r row terminator]

      [-i inputfile]            [-o outfile]             [-a packetsize]

      [-S server name]          [-U username]            [-P password]

      [-T trusted connection]   [-v version]             [-R regional enable]

      [-k keep null values]     [-E keep identity values]

      [-h "load hints"]

    It appears Column headers is a little painfull

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=192643

    Choosing a export utility: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_impt_bcp_2e5s.asp

    Field Terminator info in BCP: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_impt_bcp_2e5s.asp

  • BCP will do it. I like DTS as a quick tool to do this easily, set the properties for the text file to have column names in the first row.

  • Well, I'm looking at the union aspect of things and really not liking it, but I'll give it a shot for my application.

    And the reason I'm not wanting to do it with DTS is because honestly I don't know enough about automating it and I'm wanting to create something that will dynamically BCP data out of my database so that I can stick it into a SP that I've created.

Viewing 4 posts - 1 through 3 (of 3 total)

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