Ist „NULL = NULL“? Oder ist es doch nicht?

Der Code stammt nicht von mir und weiß leider nicht mehr wer die Abfrage geschrieben hat. Aber er/sie hat sehr gutes SELECT über dem „NULL Problem“ geschrieben:

DECLARE @Var int;
SET @Var = NULL;

IF @Var = 8 OR @Var <> 8
  PRINT 'It either is or isn''t 8';
ELSE 
  PRINT 'Huh? It''s not 8, but it''s not not 8 either!';

IF @Var = @Var
  PRINT 'Duh, of course it''s equal to itself';
ELSE 
  PRINT 'What the hey, it''s not even equal to itself!!';

 

SYSTEM_VERSIONING (Temporal Tables)

What is a system-versioned temporal table?
A system-versioned temporal table is a type of user table designed to keep a full history of data changes and allow easy point in time analysis. This type of temporal table is referred to as a system-versioned temporal table because the period of validity for each row is managed by the system

 

 
(Quelle: https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables)

Beispiel:

SELECT *
FROM Employee
FOR SYSTEM_TIME
BETWEEN '2014-01-01 00:00:00.0000000'
AND '2015-01-01 00:00:00.0000000'

Video: https://channel9.msdn.com/Shows/Data-Exposed/Temporal-in-SQL-Server-2016

Weitere sehr gute Beschreibung: http://sqlhints.com/tag/for-system_time-as-of/

 

Quelle:

http://sqlhints.com/2015/12/31/temporal-tables-in-sql-server-2016-part-2-querying-system-versioned-temporal-table/