Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporal extensions to SQL Server

Anyone know of any temporal (http://en.wikipedia.org/wiki/Temporal_database) extensions to SQL Server?

like image 776
innominate227 Avatar asked Oct 08 '13 19:10

innominate227


People also ask

What are SQL Server temporal tables?

Temporal tables (also known as system-versioned temporal tables) are a database feature that brings built-in support for providing information about data stored in the table at any point in time, rather than only the data that is correct at the current moment in time.

Are temporal tables good?

Temporal tables are considered as one of the critical features used to audit SQL Server data. The two period columns which are of datetime2 data type, SysStartTime and SysEndTime define the current and historical data for every row of the table. It defines the validity of the data.


1 Answers

I know this is an old question, but the usual solution in SQL Server is to create a "Date Dimension" database that you can join in your query. A DateDim is basically just a list of dates, but it includes columns like fiscal quarter and calendar quarter number, first/last day of that month, etc.: stuff that's difficult or time consuming to calculate on the fly but is easy to pull from a joined table.

If you search "sql date dimension" you'll find some code that will generate the table for you, though you'll need to tweak it to fit your needs. They tend to run day-by-day, but if you need hourly tracking you'll need to alter the code accordingly, for example.

like image 121
Russell Fox Avatar answered Sep 26 '22 17:09

Russell Fox