October 30, 2023 10:49 by
Peter
There are two methods for determining whether a SQL table is temporal: Examine the table definition. There are two system-versioned period entries in temporal tables: sys_start_time and sys_end_time. These columns include the beginning and end dates of the time period for which the row is valid. A table with these two columns is a temporal table.
The OBJECTPROPERTY() function should be used. The OBJECTPROPERTY() function returns information about a database object, such as whether it is a temporal table. To determine whether a table is temporal, use the SQL statement:
SELECT OBJECTPROPERTY(object_id('table_name'), 'IsTemporalTable');
If the query returns a value of 1, the table is temporal. Otherwise, the table is not chronological. For instance, the following SQL statement will determine whether the Products table is temporal:
SELECT OBJECTPROPERTY(object_id('Products'), 'IsTemporalTable');
If the result of the query is 1, then the Products table is temporal. Otherwise, the Products table is not temporal.
Note: Temporal tables are only supported in Microsoft SQL Server 2016 and later versions.
Here are some additional things to keep in mind about temporal tables:
- Temporal tables can be either system-versioned or history-table versioned. System-versioned temporal tables are managed by the database engine, while history-table versioned temporal tables are managed by the user.
- Temporal tables can be used to store both current and historical data. Current data is stored in the table, while historical data is stored in a history table.
- Temporal tables can be used to query both current and historical data. The FOR SYSTEM_TIME clause can be used to specify the time period for which the data should be returned.
HostForLIFEASP.NET SQL Server 2022 Hosting