A sample MS SQL table with datetime2 and datetimeoffset

A sample MS SQL table with columns of type datetime2 and datetimeoffset can be created as follows:

CREATE TABLE [dbo].[Test](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NULL,
	[Dt] datetime2(7),
	[Ts] datetimeoffset(7)
CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED ([Id] ASC))

Inserting a sample data row:

INSERT INTO [dbo].[Test] ([Id], [Name], [Dt], [Ts]) VALUES (1, 'first', '2016-10-23 12:45:37', '2016-10-23 12:45:37.1234567 +10:0')

Leave a Reply

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