Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system version tables generate invalid stored procedures #60

Open
pbolduc opened this issue Mar 29, 2017 · 2 comments
Open

system version tables generate invalid stored procedures #60

pbolduc opened this issue Mar 29, 2017 · 2 comments

Comments

@pbolduc
Copy link

pbolduc commented Mar 29, 2017

In SQL Server 2016, we can use system version tables which will have hidden auto generated columns. When running against, SQL Server 2016 or above, these columns should be excluded. This can be fixed by adding additional WHERE condition to the generated schemaSql.

if SELECT SERVERPROPERTY ('ProductMajorVersion') >= 13, then append "AND c.generated_always_type_desc NOT IN (N'AS_ROW_START',N'AS_ROW_END')"

@jonwagner
Copy link
Owner

I'm going through all of the open issues and working on a v3.0. Can you post sql for a table that exhibits this behavior?

@pbolduc
Copy link
Author

pbolduc commented Jun 10, 2017

Example from the docs https://docs.microsoft.com/en-us/sql/relational-databases/tables/creating-a-system-versioned-temporal-table. AutoProc tries to insert value into generated always columns.

CREATE TABLE Department
(
DeptID int NOT NULL PRIMARY KEY CLUSTERED
, DeptName varchar(50) NOT NULL
, ManagerID INT NULL
, ParentDeptID int NULL
, SysStartTime datetime2 GENERATED ALWAYS AS ROW START NOT NULL
, SysEndTime datetime2 GENERATED ALWAYS AS ROW END NOT NULL
, PERIOD FOR SYSTEM_TIME (SysStartTime,SysEndTime)
)
WITH (SYSTEM_VERSIONING = ON)
;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants