gpt4 book ai didi

sql批量插入非标准字符

转载 作者:行者123 更新时间:2023-12-04 06:03:55 27 4
gpt4 key购买 nike

我正在使用 xml 格式文件将数据从 csv 导入 sql 表。

当我执行导入时,它一切正常,但一些扩展字符显示不正确,例如“▓”,特别是“²”。

我假设这与文件的编码有关,我没有告诉导入如何处理它,但我不是 100% 确定。

我的 CSV 如下所示

"2","4567","2","234562","","MAX","","2452","m²",""," ","254352"



和我的导入文件
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR='"' />
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="12" xsi:type="CharTerm" TERMINATOR='","' />
<FIELD ID="13" xsi:type="CharTerm" TERMINATOR='"\r\n' />
</RECORD>
<ROW>
<COLUMN SOURCE="2" NAME="PARCELID" xsi:type="SQLINT"/>
<COLUMN SOURCE="3" NAME="PROPID" xsi:type="SQLINT"/>
<COLUMN SOURCE="4" NAME="LOT" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="5" NAME="RPLAN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="6" NAME="SECTION" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="7" NAME="PARISH" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="COUNTY" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="AREA" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="AREATYPE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="11" NAME="ZONING" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="12" NAME="MAPID" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="13" NAME="LOTPLAN" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>

我正在使用 sql 命令导入它
 BULK INSERT [parcel]
FROM 'c:\test\PARCEL.csv'
WITH (FORMATFILE = 'c:\test\PARCEL.xml', KEEPIDENTITY, FIRSTROW = 2, KEEPNULLS)

我的表结构看起来像
[PARCELID] [int] NOT NULL
[PROPID] [int] NULL
[LOT] [nvarchar](255) NULL
[RPLAN] [nvarchar](255) NULL
[SECTION] [nvarchar](255) NULL
[PARISH] [nvarchar](255) NULL
[COUNTY] [nvarchar](255) NULL
[AREA] [nvarchar](50) NULL
[AREATYPE] [nvarchar](255) NULL
[ZONING] [nvarchar](255) NULL
[MAPID] [nvarchar](255) NULL
[LOTPLAN] [nvarchar](255) NULL

我尝试将批量插入数据文件类型设置为“widenative”和“widechar”,但无济于事。

还有什么我在这里想念的吗?

最佳答案

原来我需要在列本身上设置排序规则,例如

<FIELD ID="10" xsi:type="CharTerm" TERMINATOR='","' COLLATION="Latin1_General_CI_AS" />

关于sql批量插入非标准字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8597608/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com