0

下面的sql在db2中运行没有问题

with mytable(a,b) as  (
    values(
    (select current timestamp from sysibm.sysdummy1), (select current timestamp from sysibm.sysdummy1))
)
select * from mytable

当我给出这个时,我想在 sql server 中运行类似的东西

with mytable(a,b) as (
values(
(select current_timestamp), (select current_timestamp))
)
select * from mytable

以下错误引发:

错误:关键字“值”附近的语法不正确。SQLState:S1000 错误代码:156 错误:“,”附近的语法不正确。SQLState:42000 错误代码:102 错误:')' 附近的语法不正确。SQLState:42000 错误代码:102

有任何想法吗 ?

4

1 回答 1

1

你可以省略values

with mytable(a, b) as (
      select current_timestamp, current_timestamp
     )
select *
from mytable;
于 2016-07-14T11:08:41.257 回答