我正在尝试使用 SQL Server 的导入和导出向导 (SQL Server 2008 R2) 导出 SQL Server 数据库。数据库模式在目标 PostgreSQL 数据库中创建得很好,大部分数据也是如此。仅当我尝试导出具有以下内容的列时,它才会崩溃NULL
第一行的值:
Error 0xc020844b: Data Flow Task 22: An exception has occurred during data insertion, the message returned from the provider is: Kan een object van het type System.Int32 niet converteren naar het type System.Char[].
(SQL Server Import and Export Wizard)
不幸的是,相关的异常是荷兰语的,但它说它无法转换类型的对象System.Int32
to System.Char[]
。原始 SQL Server 架构中列的类型是int
and integer
在生成的 PostgreSQL 数据库中。
仅当第一行中的列的值为NULL
。我认为它尝试根据列的第一个值推断数据的类型,默认为System.Char[]
如果第一个值是NULL
。有什么方法可以改变这种行为,并让数据的类型以与结果 PostgreSQL 列的类型相同的方式推断(因为它正确地做到了这一点)?
问题似乎不在 PostgreSQL 端,因此您可能应该寻找转换工具来查找错误。来自 psql:
test=# CREATE TABLE import (id int NOT NULL PRIMARY KEY, val1 int, val2 int);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "import_pkey" for table "import"
CREATE TABLE
test=# COPY import FROM STDIN (FORMAT CSV);
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> 1,,111
>> 2,22,222
>> \.
test=# SELECT * FROM import;
id | val1 | val2
----+------+------
1 | | 111
2 | 22 | 222
(2 rows)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)