2016-07-14 2 views
1

SQL unten läuft ohne Problem in db2SQL Server mit Klausel Ausgabe

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

Ich möchte etwas ähnliches in SQL Server auszuführen, wenn ich diese geben

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

Fehler unter aufwirft:

Error: Incorrect syntax near the keyword 'values'. SQLState: S1000 ErrorCode: 156 Error: Incorrect syntax near ','. SQLState: 42000 ErrorCode: 102 Error: Incorrect syntax near ')'. SQLState: 42000 ErrorCode: 102

irgendwelche ideen?

Antwort

1

Sie können values auslassen:

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