Why doesn't the FOR clause work with a SQL Server 2016 alias with temporary tables?

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

select * from Company c FOR SYSTEM_TIME all 

and got the following error: Invalid syntax next to "FOR".

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

 select * from Company FOR SYSTEM_TIME all 

I could not find documentation about this - is it a legal restriction, a known problem, or something else?

+5
source share
1 answer

It worked for me

 select * from Company FOR SYSTEM_TIME all c 
+4
source

Source: https://habr.com/ru/post/1268491/


All Articles