BCP import all files from a folder to database

 ̄綄美尐妖づ 提交于 2019-12-10 10:55:58

问题


BCP Import

How to do BCP import with all files in a folder.

folder

  • file1.csv
  • file2.csv

Need to import both the files.

bcp <tableName> in <filename> -t "^" -r "\n" -c -C 28591 -S <databaseinstance>  -U <username> -P <password>

Using the above BCP cmd, we can import only one file at a time.


回答1:


simple BCP command import only single file. To achieve the above we need to use looping with the command.

I have used the following command simple command.

for /r %i in (*) do bcp <tablename> in  %i -t "^" -r "\n" -c -C 28591 -S <databaseinstance>  -U <username> -P <password>

It works.



来源:https://stackoverflow.com/questions/38918127/bcp-import-all-files-from-a-folder-to-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!