Sunday, May 27, 2012

BCP Examples

[-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"] [-x generate xml format file] [-d database name]

*** Run the below command from command prompt ***

bcp "SELECT * FROM Items" queryout Items.csv -SSQL2008 -dkalyandb -T -t" " -c

The above query generates a csv file in the current location

-S Indicates ServerName (SQL2008)

-d kalyandb (Database Name)

-T Trusted Connection (Windows Authentication)

-t Field Terminator (" " -- Here we are specifying space)

-c Indicates Character Type File

1 comment:

  1. My brother recommended I may like this blog. He was entirely right.

    This publish truly made my day. You cann't consider just how much time I had spent for this information! Thank you!
    My web page > Recovery exchange server