我正在从SQL Server表中读取数据,并将相同的值插入PostgreSQL数据库表中。这是一个数据迁移过程。
I am reading data from SQL server table and inserting the same value in the PostgreSQL database table. It's a data migration process.
问题是SQL中的数据是纯文本,但是我在调试中看到它,它在watch中多次显示相同的值(可视studio 2015)。
The issue is that the data in the SQL is plain text but I see it in the debugging it shows same value multiple times in watch (visual studio 2015).
值在SQL Server中显示如下:
Value displays in SQL server as below:
数据在Visual Studio调试器中显示:
Data shows in the visual studio debugger:
所有迁移过程都可以正常工作,但是唯一具有这些类型的值的表不会插入PostgreSQL中,并且会引发异常。
All migration process works fine but the only table having these type of value does not insert in the PostgreSQL and will throw an exception.
例外:
{"22021: invalid byte sequence for encoding \"UTF8\": 0x00"}Stacktrace:
Stacktrace:
我无法理解确切的问题。能否请您帮助我理解上述问题的原因和解决方法。
I cannot understand the exact issue. Can you please help me understand the cause and solution of the above issue.
推荐答案我怀疑显示的内容 SQL Server中的值仅在Unicode代码点0(U + 0000)处停止,这是Windows控件默认执行的操作。看来Postgres根本不接受。
I suspect what whatever's displaying the value in SQL Server is just stopping at Unicode code point 0 (U+0000), which is what Windows controls do by default. It looks like Postgres simply doesn't accept that.
我相信您应该:
- 尝试弄清楚为什么要在SQL Server中获得像这样的价值。 (在执行插入操作的任何代码中都可能是一个错误。)
- 确定要想要的数据。如果您实际上需要U + 0000之后的数据,则需要确定这是否意味着更多的行,不同的分隔符等。
- Ether SQL Server中的数据(例如,通过在每个字段的U + 0000之前截断)或执行截断作为迁移的一部分(取决于您进行迁移的方式)。
- Try to work out why you've got the value like that in SQL Server to start with. (It could well be a bug in whatever code is doing the insert.)
- Determine what you want the data to be. If you actually need the data after U+0000, you'll need to work out whether that means more rows, a different separator etc.
- Either fix the data in SQL Server (e.g. by truncating before the U+0000 in every field) or perform the truncation as part of the migration (depending on how you're doing the migration).
更多推荐
C#数据读取器值在调试时重复多次
发布评论