在 SSIS 中导入“.csv"文件时出现奇怪的字符 [英] Strange character when importing '.csv' file in SSIS

查看:34
本文介绍了在 SSIS 中导入“.csv"文件时出现奇怪的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试使用 SSIS 将.csv"文件导入 SQL Server.导入工作正常,但我遇到的问题是,当我导入文件时,每个字段都附加了字符 .

So I'm trying to use SSIS to import a '.csv' file into SQL Server. The import works fine but the issue I'm having is that when I import the file, each field has the character � appended.

我整个上午都在尝试通过 SSIS 解决这个问题,但我没有任何运气.我刚刚注意到的是,当我打开.csv"文件并转到另存为"时,它显示为 Unicode 文本而不是实际的 csv.如果我将其保存为 csv,然后在所有字段中运行它,没有 字符.

I've been trying all morning to fix this through SSIS but I'm not having any luck. What I have just noticed is that when I open the '.csv' file and go to Save As it shows up as Unicode Text rather than an actual csv. If I save it as a csv and then run that through all the fields come through fine without the � character.

所以我有各种各样的修复,但它需要我手动打开并重新保存文件,这是我无法拥有的,因为我需要该过程能够自动运行.我曾想过使用 C# 脚本任务自动转换文件,但我不知道该怎么做,有人可以提供帮助吗?或者有没有我不知道的更好的方法?

So I have a fix of sorts but it requires me manually opening and re-saving the files, which I can't have as I need the process to be able to run automatically. I had the thought of converting the file automatically using a C# script task but I don't know how to do that, is anybody able to assist? Or is there a better way to do it that I don't know of?

谢谢.

推荐答案

您可以使用一个简单的 Powershell 脚本来更改编码:

You can use a simple Powershell script to change the encoding:

foreach ($file in Get-ChildItem *.csv) {
    Get-Content $file.name | Set-Content -Encoding utf8 "UTF8_$($file.name)"
}

这篇关于在 SSIS 中导入“.csv"文件时出现奇怪的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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