查询是否为临时表



如何检查表是暂时的从c#?如何构建查询。我需要进入一个变量表是否有版本。

你可以这样写:

SELECT t.name, t.history_table_id, t.temporal_type, t.temporal_type_desc
FROM sys.tables t

t.temporal_type/temporal_type_desc将显示表是否"启用时间",如果是,history_table_id将显示历史表的table_id

您也可以使用OBJECTPROPERTY函数

SELECT OBJECTPROPERTY(OBJECT_ID(N'dbo.YourTable'), 'TableTemporalType'); 

返回

  • 0 =非时态表
  • 1 =历史表
  • 2 =系统版本时态表

NULL,如果没有这样的表,您有权限查看。