It briefly records how to use the BCP tool to import and export data. BCP is a tool that comes with SQL server, so you only need to install it. Enter cmd in cmd and you will find some of its parameter description options. You can check the specific parameter options when using them. I will not explain them here (in fact, I do not use them too much ^_^)
A simple export example:
If you have Database A with Table B, the command for exporting data from database B is as follows:
The code is as follows: |
Copy code |
Bcp a .. B
Out
C: Currency1.txt-
C-U "sa"-p "123456"
|
Note that there are two items in the middle of A and B. If you use inheritance verification, you can remove the-u-p option and change it to-t. The following figure shows the screenshot that I executed:
To import exported data, run the following command:
The code is as follows: |
Copy code |
Bcp a .. B
In
C: Currency1.txt-
C-U "sa"-P "123456"
|
We can see that the only difference from the export is that the out is replaced with in. So far, the most concise SQL server data import and export records have been completed