Home > Software engineering >  Why constraint cannot be added?
Why constraint cannot be added?

Time:01-31

I have a graph tables and want to add constraint. Do as in the MS doc here

https://learn.microsoft.com/en-us/sql/relational-databases/tables/graph-edge-constraints?view=sql-server-2017

I do it:

ALTER TABLE bought ADD CONSTRAINT EC_BOUGHT1 CONNECTION (Customer TO Product, Supplier TO Product);

But receive the error:

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'CONNECTION'.

What is the reason? how to fix it?

CodePudding user response:

I suspect edge constraints were included in SQL Server 2017 CTP 2.0 but the feature didn't make the RTM version. I don't have an old SQL Server CTP install to verify my theory but edge constraints are not available in SQL Server 2017 RTM, at least through the latest CU (CU31 as of this writing).

Per the comments, @siggemannen submitted doc feedback to have the documentation clarified. Edge constraints are available in SQL Server 2019 and later versions, including Azure SQL Database.

  • Related