我需要从 SQL 服务器转储 table 到 utf-8 中的 csv
I need dump table from SQL Server to csv in utf-8
这有效但在 utf-8 中无效:
sqlcmd -S Server -d DB -E -s, -W -i "C:\Localdata\test.sql" | findstr /V /C:"-" /B > "C:\Localdata\Test.csv"
有人愿意帮助将其修复为 utf-8 吗?
您可以对 Unicode 格式输出文件使用 -u
开关。
但它不是 UTF-8。
sqlcmd automatically recognizes both big-endian and little-endian
Unicode input files. If the -u option has been specified, the output
will always be little-endian Unicode.
因此,例如,它禁用使用 diff 工具来比较输出。
要克服这个 M$ 的“舒适”工具 - 使用 iconv:
iconv -t UTF-8 <sqlcmd.output.csv>
再次在 Windows 作为“舒适”的 М$ 产品 - 例如,您可以使用 Git 命令行工具包中的 iconv。
在调用 sqlcmd 之前在命令行或批处理文件中键入 chcp 65001
将 -f 65001
添加到 sqlcmd 命令。 (或者 -f o:65001
如果你想要 UTF-8 输出,-f i:65001
对于 UTF-8 输入)
这有效但在 utf-8 中无效:
sqlcmd -S Server -d DB -E -s, -W -i "C:\Localdata\test.sql" | findstr /V /C:"-" /B > "C:\Localdata\Test.csv"
有人愿意帮助将其修复为 utf-8 吗?
您可以对 Unicode 格式输出文件使用 -u
开关。
但它不是 UTF-8。
sqlcmd automatically recognizes both big-endian and little-endian Unicode input files. If the -u option has been specified, the output will always be little-endian Unicode.
因此,例如,它禁用使用 diff 工具来比较输出。
要克服这个 M$ 的“舒适”工具 - 使用 iconv:
iconv -t UTF-8 <sqlcmd.output.csv>
再次在 Windows 作为“舒适”的 М$ 产品 - 例如,您可以使用 Git 命令行工具包中的 iconv。
在调用 sqlcmd 之前在命令行或批处理文件中键入 chcp 65001
将 -f 65001
添加到 sqlcmd 命令。 (或者 -f o:65001
如果你想要 UTF-8 输出,-f i:65001
对于 UTF-8 输入)