BCP 将文件夹中的所有文件导入数据库

BCP import all files from a folder to database

BCP 导入

如何对文件夹中的所有文件执行 BCP 导入。

文件夹

需要导入这两个文件。

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

使用上面的BCP命令,我们一次只能导入一个文件。

简单 BCP 命令仅导入单个文件。 要实现上述目标,我们需要在命令中使用循环。

我用过下面的简单命令

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

有效。