FOR SYSTEM_TIME CONTAINED IN
FOR SYSTEM_TIME CONTAINED IN: rows opened and closed inside the period
What changes
- Input
- temporal table current + history
- Output or change
- rows matching the period rule
Syntax at a glance
table FOR SYSTEM_TIME CONTAINED IN ( <start_date_time> , <end_date_time> )
Work example
An audit query needs FOR SYSTEM_TIME CONTAINED IN to answer a time-bounded question about a temporal table.
Use explicit UTC timestamps and test both ends of the interval. Confirm the table is system-versioned before relying on history.
Check your work FOR SYSTEM_TIME CONTAINED IN. The rows from FOR SYSTEM_TIME CONTAINED IN match the requested time boundary and current rows are not confused with history rows.
Open Microsoft Learn for full syntax, permissions, and details for your version.