Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 使用BCP将文件输出为ANSI作为UTF-8 MSSQL 2012_Sql Server_Sql Server 2012_Bcp - Fatal编程技术网

Sql server 使用BCP将文件输出为ANSI作为UTF-8 MSSQL 2012

Sql server 使用BCP将文件输出为ANSI作为UTF-8 MSSQL 2012,sql-server,sql-server-2012,bcp,Sql Server,Sql Server 2012,Bcp,我有带有国际字符的MSSQL 2012服务器数据库表。 是否有任何方法可以将表bcp输出为UTF-8格式的csv文件 当我尝试将代码页65001传递给bcp命令时,它会抛出错误: SQL 2012 does not support UTF-8. This code page (65001) is supported from SQL 2016. Error = [Microsoft][SQL Server Native Client 11.0]This version of SQL Serv

我有带有国际字符的MSSQL 2012服务器数据库表。 是否有任何方法可以将表bcp输出为UTF-8格式的csv文件

当我尝试将代码页65001传递给
bcp
命令时,它会抛出错误:

SQL 2012 does not support UTF-8. This code page (65001) is supported from SQL  2016.

Error = [Microsoft][SQL Server Native Client 11.0]This version of SQL Server Native Client does not support UTF-8 encoding (code page 65001)

找到了在
BCP
命令Powershell脚本之后运行的解决方案:

快跑

PowerShell -Command "Get-Content .\$FILE.txt | Set-Content -Encoding utf8 $FILE.utf8.txt "

找到了在
BCP
命令Powershell脚本之后运行的解决方案:

快跑

PowerShell -Command "Get-Content .\$FILE.txt | Set-Content -Encoding utf8 $FILE.utf8.txt "

代码页65001不支持SQL Server 2012(仅适用于SQL Server 2016及更高版本,SQL Server 2016(13.x)之前的重要版本不支持代码页65001(UTF-8编码)。from。您可以使用Unicode1200页面,然后手动将文件转换为首选代码页面


另外,我建议使用我的存储过程,该过程有一些改进:将表列名保存到第一行,使数据排序和其他功能更好。

代码页65001不支持SQL Server 2012(仅适用于SQL Server 2016及更高版本,SQL Server 2016(13.x)之前的重要版本)不支持代码页65001(UTF-8编码)。from)。您可以使用Unicode1200页面,然后手动将文件转换为首选代码页面

另外,我建议使用我的存储过程,它有一些改进:将表列名保存到第一行,使数据排序和其他功能变得很好