【问题标题】:SSIS: Data conversion timestamp(SQL server 2008 R2) into Bytea(PostgreSQL 9.5)SSIS:数据转换时间戳(SQL server 2008 R2)到Bytea(PostgreSQL 9.5)
【发布时间】:2017-08-21 06:42:54
【问题描述】:

我有表要从 SQL 服务器集成到 PostgreSQL。

在 SQL Server 中:

表格

CREATE TABLE tbl_binary_test
(
    Col timestamp
);

insert into tbl_binary_test values(default);
insert into tbl_binary_test values(default);

select * from tbl_binary_test;

Col
-----------------------
0x00000000000007D1
0x00000000000007D2

在 PostgreSQL 中:

表格

CREATE TABLE tbl_binary_test
(
    Col bytea
);

SSIS 包详细信息

来源:OLEDB (SQL Server)

目标:ADO NET (PostgreSQL)

数据转换尝试:

  1. 字节流 - [DT_BYTES]

输出:

\000\000\000\000\000\000\007\321
\000\000\000\000\000\000\007\322
  1. Unicode 文本流 - [DT_NTEXT]

输出:

00000000000007D1    
00000000000007D2
  1. 字符串 - [DT_STR]

输出:

00000000000007D1
00000000000007D2

问题:如何在 PostgreSQL 中插入与 SQL server 中相同的值?

【问题讨论】:

    标签: sql-server postgresql ssis


    【解决方案1】:

    我不确定我是否正确,也许decode 会满足您的需求:

    tp=# select 
      decode('00000000000007D1','hex')
    , pg_typeof(decode('00000000000007D1','hex'));
           decode       | pg_typeof
    --------------------+-----------
     \x00000000000007d1 | bytea
    (1 row)
    
    Time: 0.680 ms
    

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 2013-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多