在SQL Server时态表中使用select查询截止时间

在SQL Server时态表中使用select查询截止时间,sql,tsql,sql-server-2016,Sql,Tsql,Sql Server 2016,我的数据库中有一个时态表,可以执行以下操作: select * from tableName as of '01-nov-2019' 我也可以这样做: declare @dateToView dateTime select @dateToView = top 1 dateColumn from tableHoldingDates select * from tableName as of @dateToView 然而,我正在重写一个视图,它使用时态表,但不能声明变量 我想试着写一

我的数据库中有一个时态表,可以执行以下操作:

select * 
from tableName as of '01-nov-2019'
我也可以这样做:

declare @dateToView dateTime

select @dateToView = top 1 dateColumn 
from tableHoldingDates

select * 
from tableName as of @dateToView 
然而,我正在重写一个视图,它使用时态表,但不能声明变量

我想试着写一些东西,比如:

select * 
from tableName as of (top 1 dateColumn from tableHoldingDates)

但不能。有人知道是否可以对时态表的“截止日期”使用select吗?

视图不能参数化。您必须在
视图中硬编码
的值,或者在查询
视图时定义它。中有一些这样的示例。可能与