For more information about the parameters of the BCP tool, see books online.
This section describes how to use the following four examples: Export (out), import (in), query and export (queryout), and export and format (-f) files.
Example 1: export the entire table currency or view of the sample database adventureworks and use SQL to connect to BCP adventureworks. sales. currency out C: currency1.txt-c-u "sa"-P "password" -- use SQL connection Example 2: Same as above, use trusted connection
BCP adventureworks. Sales. Currency out C: currency1.txt-c-t -- use trusted connection Example 3: import data
BCP adventureworks. Sales. currency1 in C: currency1.txt-c-t or import 10-13 rows of specified data
BCP adventureworks. Sales. currency1 in C: currency1.txt-C-f 10-L 13-T
Example 4: Use query to export data
BCP "select top 20 * From adventureworks. sales. currency "queryout C: currency2.txt-f 10-L 13-c-u" sa "-P" password "-s" ip "or
BCP "select Top 4 * From adventureworks. sales. currency where id not in (select Top 9 ID from adventureworks. sales. currency "queryout C: currency2.txt-c-u" sa "-P" password "-s" ip"
Example 5: export a formatted file:
Exec master.. xp_mongoshell 'bcp adventureworks. Sales. Currency format NUL-f c: currency_format1.fmt-c-t
Finally: The above is the BCP tool of the client, you can also use the BCP of the server from the client
Exec master .. xp_mongoshell 'bcp "select top 20 * From adventureworks. Sales. Currency" queryout C: cur.txt-f 10-L 13-c-t
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/zhou__zhou/archive/2007/08/10/1736310.aspx