为什么FOR子句不能在带有临时表的SQL Server 2016中与别名一起使用? [英] Why does the FOR Clause not work with an alias in SQL Server 2016 with temporal tables?
本文介绍了为什么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
这篇关于为什么FOR子句不能在带有临时表的SQL Server 2016中与别名一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文