简体   繁体   中英

Why does the FOR Clause not work with an alias in SQL Server 2016 with temporal tables?

I have a SQL Server 2016 database with temporal tables. One temporal table is called Company. I am trying to query it to get current records and all historical records. I first tried the following query:

select *
from Company c
FOR SYSTEM_TIME all

and got the following error: Incorrect syntax near 'FOR'.

However, if I try it without the alias it works fine:

select *
from Company
FOR SYSTEM_TIME all

I could not find any documentation about this- is it a legitimate constraint, a known issue, or something else?

This worked for me

select *
from Company FOR SYSTEM_TIME all c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM