为什么FOR子句不能在带有临时表的SQL Server 2016中与别名一起使用?
问题描述:
我有一个带有时态表的SQL Server 2016数据库.一个临时表称为Company.我正在尝试查询它以获取当前记录和所有历史记录.我首先尝试了以下查询:
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
,并出现以下错误: "FOR"附近的语法不正确.
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?
答
这对我有用
select *
from Company FOR SYSTEM_TIME all c