wise-coders / dbschema

DbSchema Database Designer
https://dbschema.com
67 stars 3 forks source link

Adding a SQL Server computed column will always result in an error #83

Closed NeilN1 closed 1 year ago

NeilN1 commented 1 year ago

DbSchema 9.1.3 build 221114

Adding a computed column will result in a script like this: ALTER TABLE [xxx].dbo.Contact ADD Address1Composite AS COALESCE(Address1Line1 + ' ', '') + COALESCE(Address1Line2 + ' ', '') + COALESCE(Address1Line3 + ' ', '') + COALESCE(Address1City + ' ', '') + COALESCE(Address1Province + ' ', '') + COALESCE(Address1PostalCode, '') NULL

Causing the error: Only UNIQUE or PRIMARY KEY constraints can be created on computed columns, while CHECK, FOREIGN KEY, and NOT NULL constraints require that computed columns be persisted.

Dropping the NULL solves the issue. See last post of https://stackoverflow.com/questions/45727140/sql-only-unique-or-primary-key-constraints-can-be-created-on-computed-columns

wise-coders commented 1 year ago

Thank you for writing about this issue. A fix will be available tomorrow under: https://dbschema.com/beta.php The version number will be the same, the build number will increase.