SNOWFLAKE 插入失败——无法识别时间戳“06/28/2016 20:35:06:703000”

SNOWFLAKE insert failing -- Timestamp '06/28/2016 20:35:06:703000' is not recognized

我正在尝试将数据从 SQL 服务器加载到 Snowflake 环境。 SQL 将日期输出为 --06/28/2016 20:35:06:703000'

在使用时间戳 (9) 作为数据类型将此值插入雪花时,出现此错误 -- 无法识别时间戳“06/28/2016 20:35:06:703000”

如果我插入-- '06/28/2016 20:35:06' --> 正在插入。

我试过了

  1. 更改会话设置 TIMESTAMP_OUTPUT_FORMAT = 'AUTO';
  2. 更改会话集 TIMESTAMP_INPUT_FORMAT = 'MM-DD-YYYY HH24:MM:SS.FF6';
  3. 更改会话设置 TIMESTAMP_INPUT_FORMAT = 'AUTO';
    1. 更改会话设置 TIMESTAMP_INPUT_FORMAT = 'MM/DD/YYYY HH24:MM:SS.FF6';

目前没有任何效果。

有人可以帮忙吗?

如果我使用你的格式字符串的小写版本,它对我有用:

好吧,如果 mi 用于分钟,parameters format 并且毫秒标记是 : 而不是 . 在您的示例数据

select  '06/28/2016 20:35:06:703000' as inp
    ,try_to_timestamp(inp, 'mm/dd/yyyy hh:mi:ss:ff6') as ts1
    ,try_to_timestamp(inp, 'mm/dd/yyyy hh24:mi:ss:ff6') as ts1b
    ,try_to_timestamp(inp, 'MM/DD/YYYY HH24:MM:SS.FF6') as ts2
    ,try_to_timestamp(inp, 'MM/DD/YYYY HH:MI:SS.FF6') as ts3
    ,try_to_timestamp(inp, 'MM/DD/YYYY HH:MI:SS.FF6') as ts4
    ;
INP TS1 TS1B TS2 TS3 TS4
06/28/2016 20:35:06:703000 2016-06-28 20:35:06.703 2016-06-28 20:35:06.703 null null null

会话格式:

ALTER SESSION SET TIMESTAMP_INPUT_FORMAT = 'mm/dd/yyyy hh:mi:ss:ff6';
select '06/28/2016 20:35:06:703000'::timestamp;

似乎对我有用,尽管实际上仍然不是插入

'06/28/2016 20:35:06:703000'::TIMESTAMP
2016-06-28 20:35:06.703

有数据插入:

ALTER SESSION SET TIMESTAMP_INPUT_FORMAT = 'mm/dd/yyyy hh:mi:ss:ff6';

create table ts_test(ts timestamp_ntz);

insert into ts_test  select '06/28/2016 20:35:06:703000';

select * from ts_test;
TS
2016-06-28 20:35:06.703

这也适用于我:

insert into ts_test values ('06/28/2016 20:35:06:703000');