2

I am running SQL Server 2016 SP1 (13.0.4001) on Windows Sever 2012 R2. I have the below table.

CREATE TABLE [SubEx].[Ingredients](
    [IngredientId] [int] IDENTITY(1,2) NOT NULL,
    [IngredientName] [nvarchar](328) NOT NULL,
    [IngredientShortDescription] [nvarchar](328) NOT NULL,
    [PortionUOMTypeId] [smallint] NULL,
    [WISRTypeId] [smallint] NOT NULL,
    [WISRSubTypeId] [smallint] NULL,
    [FlavorTypeId] [smallint] NULL,
    [StatusTypeId] [smallint] NOT NULL,
    [IsMandatory] [bit] NOT NULL,
    [IsDownloaded] [bit] NOT NULL,
    [CreatedDT] [datetime] NOT NULL,
    [CreatedBy] [int] NOT NULL,
    [LastUpdateDT] [datetime] NULL,
    [LastUpdateBy] [int] NULL,
    [Deleted] [bit] NOT NULL,
    [DeletedDT] [datetime] NULL,
    [DeletedBy] [int] NULL,
    [CreatedUserName] [nvarchar](136) NOT NULL,
    [UpdatedUserName] [nvarchar](136) NULL,
    [DeletedUserName] [nvarchar](136) NULL,
    [ValidFrom] [datetime2](2) GENERATED ALWAYS AS ROW START NOT NULL,
    [ValidTo] [datetime2](2) GENERATED ALWAYS AS ROW END NOT NULL,
 CONSTRAINT [PK_Ingredients_IngredientId] PRIMARY KEY CLUSTERED 
(
    [IngredientId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY],
    PERIOD FOR SYSTEM_TIME ([ValidFrom], [ValidTo])
) ON [PRIMARY]

GO

ALTER TABLE [SubEx].[Ingredients] ADD  CONSTRAINT [DF_Ingredients_IsMandatory]  DEFAULT ((0)) FOR [IsMandatory]
GO

ALTER TABLE [SubEx].[Ingredients] ADD  CONSTRAINT [DF_Ingredients_IsDownloaded]  DEFAULT ((0)) FOR [IsDownloaded]
GO

ALTER TABLE [SubEx].[Ingredients] ADD  CONSTRAINT [DF_Ingredients_Deleted]  DEFAULT ((0)) FOR [Deleted]
GO

ALTER TABLE [SubEx].[Ingredients] ADD  CONSTRAINT [DF_ValidFrom]  DEFAULT (dateadd(second,(-1),sysutcdatetime())) FOR [ValidFrom]
GO

ALTER TABLE [SubEx].[Ingredients] ADD  CONSTRAINT [DF_ValidTo]  DEFAULT ('9999.12.31 23:59:59.99') FOR [ValidTo]
GO

ALTER TABLE [SubEx].[Ingredients]  WITH CHECK ADD  CONSTRAINT [FK_Ingredients_TlkpFlavorTypes_FlavorTypeId] FOREIGN KEY([FlavorTypeId])
REFERENCES [SubEx].[TlkpFlavorTypes] ([FlavorTypeId])
GO

ALTER TABLE [SubEx].[Ingredients] CHECK CONSTRAINT [FK_Ingredients_TlkpFlavorTypes_FlavorTypeId]
GO

ALTER TABLE [SubEx].[Ingredients]  WITH CHECK ADD  CONSTRAINT [FK_Ingredients_TlkpStatusTypes_StatusTypeId] FOREIGN KEY([StatusTypeId])
REFERENCES [SubEx].[TlkpStatusTypes] ([StatusTypeId])
GO

ALTER TABLE [SubEx].[Ingredients] CHECK CONSTRAINT [FK_Ingredients_TlkpStatusTypes_StatusTypeId]
GO

ALTER TABLE [SubEx].[Ingredients]  WITH CHECK ADD  CONSTRAINT [FK_Ingredients_TlkpWISRCategoryTypes_WISRTypeId] FOREIGN KEY([WISRTypeId])
REFERENCES [SubEx].[TlkpWISRCategoryTypes] ([WISRTypeId])
GO

ALTER TABLE [SubEx].[Ingredients] CHECK CONSTRAINT [FK_Ingredients_TlkpWISRCategoryTypes_WISRTypeId]
GO

ALTER TABLE [SubEx].[Ingredients]  WITH CHECK ADD  CONSTRAINT [FK_Ingredients_TlkpWISRSubCategoryTypes_WISRSubTypeId] FOREIGN KEY([WISRSubTypeId])
REFERENCES [SubEx].[TlkpWISRSubCategoryTypes] ([WISRSubTypeId])
GO

ALTER TABLE [SubEx].[Ingredients] CHECK CONSTRAINT [FK_Ingredients_TlkpWISRSubCategoryTypes_WISRSubTypeId]
GO

When I run the below script to enable SYSTEM_VERSIONING for my temporal table, I receive the below error message and a stack dump.

ALTER TABLE SubEx.Ingredients
    SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = SubEx.IngredientsHistory));

Msg 596, Level 21, State 1, Line 8 Cannot continue the execution because the session is in the kill state.

Msg 0, Level 20, State 0, Line 8 A severe error occurred on the current command. The results, if any, should be discarded.

Am I doing something wrong or do I need to submit a bug with Microsoft?

  • I couldn't run your entire script due to FK errors, but as far as simple system-versioning setup, I could not recreate the problem you're encountering. – Scott Hodgin Feb 17 '17 at 14:45
  • Anytime there is a "Severe error" I would submit a support ticket to Microsoft to properly debug it. – George Walters Feb 17 '17 at 14:47
4

This might be your problem:

A dump file is generated when you enable system-versioning on a table in SQL Server 2016

Try installing CU1 of Sql 2016 SP1

  • Microsoft is recommending the same thing. I am in the middle of installing and testing now. – SQL Hammer Feb 17 '17 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.