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

爷,独闯天下 提交于 2019-12-08 19:47:36

问题


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?


回答1:


This worked for me

select *
from Company FOR SYSTEM_TIME all c


来源:https://stackoverflow.com/questions/44337046/why-does-the-for-clause-not-work-with-an-alias-in-sql-server-2016-with-temporal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!