ssis 转换中文字符乱码

This article explores the Character Map Transformation in SSIS package with available configurations.

本文探讨了具有可用配置的SSIS包中的字符映射转换。

介绍 (Introduction)

In the previous article, we explored SQL Server commands to change text case in the following scenarios.

在上一篇文章中,我们探讨了在以下情况下更改文本大小写SQL Server命令。

  1. Lowercase to Uppercase using SQL UPPER function 使用SQL UPPER函数将小写字母转换为大写字母
  2. Uppercase to Lowercase with SQL LOWER function 使用SQL LOWER函数从大写到小写
  3. Change the first character of each word in a string to a capital letter. We do not have any available function in SQL Server to do that. We performed this task using a custom function T-SQL code 将字符串中每个单词的第一个字符更改为大写字母。 在SQL Server中,我们没有任何可用的功能。 我们使用自定义函数T-SQL代码执行了此任务

As you can see here, we have limited functions in SQL Server to convert the character case transformations. It is possible, but you should be a T-SQL programming expert and able to write complex queries.

如您所见,SQL Server中用于转换字符大小写转换的功能有限。 可以,但是您应该是T-SQL编程专家,并且能够编写复杂的查询。

You might have heard a famous proverb – A FRIEND IN NEED IS A FRIEND INDEED.

您可能已经听过一句著名的谚语- “需要的朋友才是真正的朋友”

You might be thinking about the relationship of this proverb with this article. I use this quote for the true friend of DBA and Developers in SQL Server – SSIS Package. Yes, we can easily do character case transformations using SSIS packages. We use Character map transformation in SSIS package to achieve this task.

您可能正在考虑这个谚语与本文的关系。 我将此报价用于SQL Server – SSIS包中DBA和开发人员的真正朋友。 是的,我们可以使用SSIS包轻松进行字符大小写转换。 我们使用SSIS包中的Character map转换来完成此任务。

Let’s explore this transformation in this article in details.

让我们在本文中详细探讨这种转换。

本文的先决条件 (Pre-requisites for this article)

  • SQL Server instance with integration services 具有集成服务SQL Server实例
  • SQL Server Data tools SQL Server数据工具
  • Sample database – AdventureWorks 示例数据库– AdventureWorks

In the sample database AdventureWorks, we have the following data in the [ProductDescription] table.

在示例数据库AdventureWorks中,我们在[ProductDescription]表中具有以下数据。

SELECT TOP (10) [ProductDescriptionID],[Description]FROM [adventureworks2014].[Production].[ProductDescription]

We will use data in description column as a source in this article.

本文将使用描述列中的数据作为源。

SSIS包中的字符映射转换概述 (Overview of Character map transformation in SSIS package)

In SSIS Toolbox, we have the following Character Map transformation.

在SSIS工具箱中,我们进行以下字符映射转换。

In the Character Map, it provides the following mapping operations.

在字符映射表中,它提供以下映射操作。

Let’s get a brief overview of each operations in character map transformation.

让我们简要概述一下字符映射转换中的每个操作。

小写 (Lowercase)

It converts all text into lowercase. It is similar to SQL Lower function. Example: car becomes CAR.

它将所有文本转换为小写。 它类似于SQL Lower函数。 示例:汽车变成汽车。

大写 (Uppercase)

It converts all text into uppercase. It is similar to a SQL UPPER function. Example: CAR becomes a car.

它将所有文本转换为大写。 它类似于SQL UPPER函数。 示例:CAR变成一辆汽车。

字节反转 (Byte reversal)

It reverses the order of byte of Unicode.

它颠倒了Unicode字节的顺序。

平假名 (Hiragana)

It converts Katakana characters to Hiragana characters.

它将片假名字符转换为平假名字符。

  • Katakana and Hiragana both are characters in a Japanese syllabary 片假名和平假名都是日语音节中的字符
  • In the following image, you can see both characters 在下图中,您可以看到两个字符

片假名 (Katakana)

It converts Hiragana characters to Katakana characters.

它将平假名字符转换为片假名字符。

一半的宽度 (Half-width)

We use this option to convert full-width character to half-width character. In full-width character, you have the same width for each character and similar to Chinese character. It does not depend upon the character set. Half-width characters occupy half-space compared to full-width characters.

我们使用此选项将全角字符转换为半角字符。 在全角字符中,每个字符的宽度相同,与汉字相似。 它不取决于字符集。 与全角字符相比,半角字符占据一半的空间。

  • Full-width example: full width 全角示例:full width
  • Half-width example: fullwidth 半角示例:全角

全屏宽度 (Full width)

This option performs reverse work of the half-width. It coverts half-width characters into full-width character.

此选项执行半角的反向工作。 它会将半角字符转换为全角字符。

语言框 (Linguistic casing)

  • Usually, SQL Server uses system language to insert data into tables. Example: date format. If your system uses date format in US format, SQL also uses the same format by default. We can use Linguistic casing to use other local languages.

    通常,SQL Server使用系统语言将数据插入表中。 示例:日期格式。 如果您的系统使用美国格式的日期格式,则默认情况下,SQL也使用相同的格式。 我们可以使用语言大小写来使用其他本地语言。

简体中文 (Simplified Chinese)

We can use this option to convert traditional Chinese characters to Simplified Chinese characters.

我们可以使用此选项将繁体中文字符转换为简体中文字符。

    • Example: My name is Rajendra becomes 我的名字是拉金德拉 in traditional Chinese 示例:我的名字叫Rajendra成为我的名字是拉金德拉
    • Example: My name is Rajendra becomes 我的名字是拉金德拉 in simplified Chinese 示例:我的名字叫Rajendra成为简体中文的我的名字是拉金德拉

Note: I used Google translate to show these conversions.

注意:我使用Google翻译显示了这些转换。

繁体中文 (Traditional Chinese)

It converts simplified Chinese characters to Traditional Chinese characters.

它将简体中文字符转换为繁体中文字符。

  • Example: Converts text (My name is Rajendra) 我的名字是拉金德拉 to 我的名字是拉金德拉 示例:将文本(我的名字是Rajendra)转换为我的名字是拉金德拉

We can use multiple options for a column using Character Map transformation in SSIS package. There are few exclusions as well.

我们可以使用SSIS包中的Character Map转换为列使用多个选项。 也有一些例外情况。

SSIS软件包中字符映射转换中的排除项 (Exclusion in Character Map Transformation in SSIS package)

The simplest example is lowercase and uppercase. Suppose we used lowercase to convert all characters into lowercase. We should not use an uppercase option in this case as it is opposite to the lowercase option. In the following image from Microsoft docs, you can find mutually exclusive operations.

最简单的示例是小写和大写。 假设我们使用小写字母将所有字符转换为小写字母。 在这种情况下,我们不应使用大写选项,因为它与小写选项相反。 在Microsoft docs的下图中,您可以找到互斥的操作。

在SSIS程序包中配置字符映射转换,用于 (Configure Character Map Transformation in an SSIS package for)

Let’s create an ETL to use Character Map transformation in SSIS package.

让我们创建一个ETL以在SSIS包中使用Character Map转换。

Drag a Data flow task in the control flow area and rename it as Character Map Transformation in SSIS.

将数据流任务拖到控制流区域中,并将其重命名为SSIS中的“角色映射转换”。

In the data flow tab, add an OLE DB source and configure a connection to point our source database Adventureworks. Rename this OLE DB source to ProductDescription.

在数据流选项卡中,添加OLE DB源并配置连接以指向我们的源数据库Adventureworks。 将此OLE DB源重命名为ProductDescription。

Change data access mode to SQL command and specify SQL query in this.

将数据访问模式更改为SQL命令,并在其中指定SQL查询。

Click on Columns and remove the tick on ProductDescriptionID column. We want source column as description.

单击列,然后删除ProductDescriptionID列上的勾号。 我们希望源列作为描述。

Join the ProductDescription task to Character Map, as shown below.

将ProductDescription任务加入Character Map,如下所示。

We need to configure the appropriate options in the Character Map. Double click on it, and it opens the Character map transformation editor. In the transformation editor, it shows you all available columns in the source table. Let’s do the following configurations.

我们需要在字符映射表中配置适当的选项。 双击它,它会打开“角色图转换”编辑器。 在转换编辑器中,它显示源表中所有可用的列。 让我们进行以下配置。

  • Select the column name description in the available input columns table 在可用的输入列表中选择列名称描述
  • Select destination as New Column. We can replace the existing column as well by selecting option In-place change. It is good to use a new column so that we can compare the original and converted text at one place
  • 选择目标作为新列 。 我们还可以通过选择就地更改选项来替换现有列 最好使用新列,以便我们可以在一个地方比较原始文本和转换后的文本
  • lowercase. We want to convert all text into a lower case character 小写。 我们希望将所有文本转换为小写字符
  • In the output alias, we can specify the name of a new column after case conversion. I specified the new column as Description_new 在输出别名中,我们可以指定大小写转换后新列的名称。 我将新列指定为Description_new

You can add an OLE DB destination to get the data into a SQL Server table. For this demo, we want to view the behavior of Character map Transformation in SSIS package. Let’s add a SQL multicast and join it with the character map as shown below.

您可以添加OLE DB目标以将数据获取到SQL Server表中。 对于此演示,我们想查看SSIS包中的Character map Transformation的行为。 让我们添加一个SQL多播并将其与字符映射表连接起来,如下所示。

Right-click on the arrow between Character Map and Multicast and enable data viewer. You can view the data after the character map transformation using this data viewer.

右键单击“字符映射”和“多播”之间的箭头,然后启用数据查看器。 您可以使用此数据查看器在字符映射转换后查看数据。

You can see the following symbol on the arrow for data viewer.

您可以在数据查看器的箭头上看到以下符号。

Execute the SSIS package from the Start button or press F5. In the data viewer, you can see column description (original) and description_new(new) in lowercase. All characters in description_new column are in lowercase.

从“开始”按钮执行SSIS程序包或按F5。 在数据查看器中,您可以以小写形式查看列描述(原始)和description_new(新)。 description_new列中的所有字符均为小写。

Let’s try a few other operations as well. We cannot do this while the package is executing. First, Stop the SSIS package execution (press Shift + F5) and change the operation as Uppercase as shown in following the image.

我们也尝试其他一些操作。 程序包执行时我们无法执行此操作。 首先,停止执行SSIS包(按Shift + F5),然后将操作更改为大写,如下图所示。

Re-execute the package, and it converts Uppercase operation for the input data. In the output, you can see all the characters in uppercase.

重新执行该程序包,然后它将大写操作转换为输入数据。 在输出中,您可以看到所有大写字符。

Let’s change the operation to Full Width and observe the output.

让我们将操作更改为“ 全宽”并观察输出。

Click Ok and execute the SSIS package. It changes the characters font and spacing, as shown below.

单击“确定”并执行SSIS包。 它将更改字符的字体和间距,如下所示。

As highlighted earlier, we cannot use two operations that are not compatible with each other. For example, let’s select both lowercase and uppercase operations together, and you get the following error message.

如前所述,我们不能使用两个互不兼容的操作。 例如,让我们同时选择小写和大写操作,您会收到以下错误消息。

Similarly, we cannot use Uppercase and half-width operation together on the same column. You can refer the table shown in the above section for the mutually exclusive operations.

同样,我们不能在同一列上同时使用大写和半角运算。 您可以参考上一节中显示的表进行互斥操作。

结论 (Conclusion)

In this article, we explored Character Map Transformation in SSIS package to convert the case of the characters using SSIS. You can easily change the configuration from the available operations and get the desired output.

在本文中,我们探索了SSIS包中的字符映射转换,以使用SSIS转换字符的大小写。 您可以轻松地从可用操作中更改配置并获得所需的输出。

翻译自: https://www.sqlshack.com/character-map-transformation-in-ssis-packages/

ssis 转换中文字符乱码

ssis 转换中文字符乱码_SSIS软件包中的字符映射转换相关推荐

  1. 关于python中的字符串映射转换

    关于python中的字符串映射转换 利用Python字符串映射的方式来快速准确对Python字符串中对应的字符串进行替换,方法主要有两种: 第一种:maketrans方法 maketrans方法的参数 ...

  2. C语言试题六十三之请编写函数fun:将s所指字符串中ascii值为偶数的字符删除,串中剩余字符形成一个新串放在t所指的数组中。

    1. 题目 请编写函数fun,其功能是:将s所指字符串中ascii值为偶数的字符删除,串中剩余字符形成一个新串放在t所指的数组中. 2 .温馨提示 C语言试题汇总里可用于计算机二级C语言笔试.机试.研 ...

  3. C语言试题六十一之请编写函数fun:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成新串放在t所指数组中。

    1. 题目 请编写函数fun,其功能是:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成新串放在t所指数组中. 2 .温馨提示 C语言试题汇总里可用于计算机二级C语言笔试.机试.研究生复试中C程 ...

  4. 关于VS2017调试时,字符数组显示字符串中的字符无效问题

    关于VS2017调试时,字符数组显示"字符串中的字符无效"问题 1.如果已经分配过内存,可能是越界导致的指令错误. 2.可能是字符数组成员的值超出了ASCII码表示范围,导致字符无 ...

  5. ssis 列转换_SSIS包中的行采样转换和百分比采样转换

    ssis 列转换 This article explores Row Sampling Transformations in SSIS and Percentage Sampling Transfor ...

  6. 修改oracle客户端的编码,Oracle中文字符乱码?设置Oracle客户端字符编码与服务端一致...

    经常可能出现查询Oracle数据时,中文显示乱码,这很可能是因为,Oracle服务端的字符编码与客户端不一致引起的. 这时,我们需要做的是,如何设置自己的客户端字符编码与服务端一致. 查询Oracle ...

  7. 手机号码转码_中文域名转码,中文域名PunyCode编码转换,中文域名在线转码工具,Punycode编码在线转换工具...

    中文域名分为两类: 1.一类是域名后缀为英文字母的国际中文域名和别国中文域名,比如:中文.com,中文.net,中文.biz,中文.cc,中文.hk,中文.tm,中文.tv,中文.tw: 2.一类是域 ...

  8. python删除字符串中重复字符_删除字符串中重复字符python 用CAD怎么画DNA反向

    用CAD怎么画DNA反向平行双螺旋结构绘螺旋线时,用选扭曲,确定顺时针. 画双头螺旋线时,第二根螺旋线底圆起点与第一根螺旋线底圆起点,可用角度分隔如180°.python去除文本中重复的字符串可有可无 ...

  9. php 删除字符串里指定字符,php删除字符串中指定字符_php删除字符串

    在做项目时需要对一个字符串进行处理,也就是删除指定的字符,吾爱编程通过这篇文章主要介绍了PHP实现删除字符串中任何字符的函数,涉及php针对字符串的遍历与截取操作技巧,需要的朋友可以参考一下: PHP ...

最新文章

  1. webstrom Certificate validation failed
  2. 日积月累:ProguardGui进行jar包代码混淆
  3. 【数学建模】MATLAB应用实战系列(九十一)-熵权法应用案例(附MATLAB和Python代码)
  4. Hadoop 2.0(YARN/HDFS)学习资料汇总
  5. 新手学java_新手如何学习Java
  6. Android 折叠头部监听,抽屉式动画
  7. 扔掉目标检测器,实现真正的端到端多模态预训练!阿里提出E2E-VLP(ACL2021)...
  8. 计算机班服设计图片大全,有创意的班服设计图片,班服图案图片,霸气班服logo图案大全...
  9. js获取(URL)地址栏参数
  10. IT业十大热门职位介绍 (转)
  11. 【centos6.5】安装LNMP(linux公社)
  12. 手机阅读行业分析(beta)
  13. win7装matlab教程,win7系统怎么安装matlab软件(图文教程)
  14. 微信公众号批量打标签的自动化实现方法
  15. 谷歌地图 图片保存_Google如何在地图上跟踪并保存您的一举一动
  16. Ubuntu 21.04 虚拟机设置共享文件夹
  17. MRCTF 2020-“TiKi小组”
  18. Bzoj 1596: [Usaco2008 Jan]电话网络
  19. Linux磁盘分区工具fdisk和gdisk的区别
  20. zabbix监控配置QQ邮箱服务

热门文章

  1. nvme分区选mbr还是guid_win10 双系统 Ubuntu UEFI+GPT bios+mbr 理论与实践
  2. Golang postgres.go:45:3: unknown field ‘WithReturning‘ in struct literal of type....
  3. nginx 如何查看访问ip和对应访问路径
  4. 数据分析师的工资水平如何?
  5. 人人都能成为闪电网络节点:第7章管理lnd
  6. 《精通.NET互操作:P/Invoke、C++ Interop和COM Interop》
  7. 什么是HTTP状态码 常见状态码集合
  8. Oracle和MySql的布尔类型
  9. 数字化名词解释—数字化
  10. 专家系统java编程_专家系统的Java实现