Wednesday, August 1, 2007

Sql Server - BCP (Bulk copy program)

Bulk copy program is a very useful tool to be used when populating bulk data to the DB when load testing though it is not the intended usage of it. It created to set transfer bulk copies from server to any other in case of a batch transfer.

The simple command template is:
bcp <Db name>.dbo.<table name> in <file name> -c -t, -S<db server name> -U<user name> -P<password>

bcp MyDB.dbo.User out c:\users.txt -c -t, -S192.168.100.01 -Ume -Ptest

When you use "out", it will output table data to the specified file. By simply changing "out" to "in", you can easily input data from a text file you already have.

The above is for using sql server authentication to login to the server. If you need to use windows authentication, you need to add "-T" switch also. There are lot of other switches you can use with this command.

No comments: