如何在SQL Server中使用批量插入来编写UTF-8字符? [英] How to write UTF-8 characters using bulk insert in SQL Server?

查看:183
本文介绍了如何在SQL Server中使用批量插入来编写UTF-8字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对sqlserver进行大容量插入,并且未将UTF-8字符正确插入数据库中.数据文件包含这些字符,但是执行批量插入后,数据库行中包含垃圾字符.

I am doing a BULK INSERT into sqlserver and it is not inserting UTF-8 characters into database properly. The data file contains these characters, but the database rows contain garbage characters after bulk insert execution.

我的第一个怀疑者是格式文件的最后一行:

My first suspect was the last line of the format file:

10.0
3
1 SQLCHAR  0  0  "{|}"  1 INSTANCEID ""
2 SQLCHAR  0  0  "{|}"  2 PROPERTYID ""
3 SQLCHAR  0  0  "[|]"  3 CONTENTTEXT "SQL_Latin1_General_CP1_CI_AS"

但是,在阅读官方页面在我看来,这实际上是SQL Server 2008版中通过插入操作读取数据文件的错误.我们使用的是2008 R2版.

But, after reading this official page it seems to me that this is actually a bug in reading the data file by the insert operation in SQL Server version 2008. We are using version 2008 R2.

该问题的解决方案是什么,或者至少是解决方法?

What is the solution to this problem or at least a workaround?

推荐答案

您不能.您应该首先使用N类型的数据字段,将文件转换为UTF-16,然后导入.该数据库不支持UTF-8.

You can't. You should first use a N type data field, convert your file to UTF-16 and then import it. The database does not support UTF-8.

这篇关于如何在SQL Server中使用批量插入来编写UTF-8字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆