Back
Database Management

Reliable database management for modern, high-performance systems.

Back
Data Modernisation

Reliable database management for modern, high-performance systems.

Back
Data Engineering

Reliable database management for modern, high-performance systems.

Back
Analytics & Intelligence

Reliable database management for modern, high-performance systems.

Back
Data Strategy Consulting

Reliable database management for modern, high-performance systems.

System Versioned Tables In SQL Server

Thirunavukkarasu RM
Published on
April 1, 2021

Feature introduced from SQL Server 2016

One of the easiest option to configure data audit is using system versioned table. Lets taken a scenario if you have a critical table to do an audit on transactions you might have to write triggers or events, but now you can use Versioned table to setup audit easier.

Lets begin with example to create versioned table

Conditions while creating new versioned table

  • Table must have primary Key
  • Declare two datetime2 type columns
  • Specify PERIOD FOR SYSTEM_TIME
  • If you not mentioned any table name for history, sql server itself generate new table.

Below is the example to specify the history table details along with main table creation.

Versioned table under database

Now lets begin to insert data in to invoice table and then understand the usage of versioned table.

Now let change the amount value on existing records and see the changes on history table.

Easily we can track any update/Delete with this versioned table option. But there are some limitations while using this option

  • Replication would not support for any Temporal tables

Thirunavukkarasu RM

Thirunavukkarasu Ramasamy has 17+ years of experience in database management and the Microsoft Data Platform, with expertise in SQL Server, database architecture, and data solutions. As the Senior Solution Architect of Geopits, he focuses on building scalable data platforms, modernizing database environments, and delivering reliable enterprise data solutions.

Our Latest Blogs

From monitoring to modernization, GeoPITS provides expert database management services that enhance performance, strengthen security, and reduce operational costs.

Ready to Transform Your Data?

Geopits works alongside your team as a strategic partner, starting with stabilizing your current databases, then modernizing your data infrastructure, and ultimately helping you unlock the full potential of AI.

170

Happy Clients so far

2100+

Databases Managed

142+

Successful Migrations

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.