Quiz: Temporal Tables 101

Quiz: Temporal Tables 101

These questions are based on the following schema and data:
CREATE TABLE dbo.tasks
(
    taskid INT IDENTITY NOT NULL,
    taskdescription NVARCHAR(256),
    validfrom DATETIME2(0) GENERATED ALWAYS AS ROW START NOT NULL,
    validto DATETIME2(0) GENERATED ALWAYS AS ROW END NOT NULL,
    PERIOD FOR SYSTEM_TIME(validfrom, validto),
    CONSTRAINT pk_OpinionsDefault
        PRIMARY KEY CLUSTERED (taskid)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.taskhistory));
GO

INSERT dbo.tasks (taskdescription)
VALUES  ( 'pack suitcase for SQL in the City'),
        ( 'write presentation'),
        ( 'walk doggos');
GO
  • SELECT *
    FROM dbo.tasks;
  • DELETE FROM dbo.tasks
    WHERE taskdescription = N'walk doggos';
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.