Applies to: SQL Server tables changed with ALTER TABLE ADD; no Clarion or SQL Server version is named in the thread.
Problem
Each time a column is added to a table, a constraint appears, for example ALTER TABLE [dbo].[tpastk] ADD DEFAULT ('') FOR [stk_Parent], or DEFAULT ((0)) for a number. The poster could not tell whether File Manager 3 or Clarion caused it, deleted the constraints by hand without trouble, and asked how to stop them being created.
Solution
- SQL Server needs a value for the existing rows. Dennis E. quoted the rule: ALTER TABLE adds a column only if it can hold nulls, has a DEFAULT, is an identity or timestamp column, or the table is empty.
- The poster tested
Alter Table dbo.tpalib add lib_posNo int Default 0and found MSSQL itself creates the constraint with it. No switch to turn that off came up in the thread. - Once the column exists and the table holds data, removing the constraint is fine (Dennis E.). Leaving it was advised: a default helps documentation and avoids nulls (Dennis E., John S.).
- A column that allows nulls needs no default in the statement (Jon W., who does not use MSSQL and said so).
Caveats
- John S. argued for keeping defaults because other programs adding rows need not know which columns are nullable.
- Jon W. prefers NULL for missing data in analysis work; the thread left the choice to the reader.
- Who emits the DEFAULT clause, FM3 or Clarion, was never settled.
Today (2026)
Not re-tested. The server rule for adding columns to non-empty tables likely still holds.
Sources: Edmond S. (Jun 2013, the question), Dennis E., John S., Jon W. (Jun and Jul 2013) in softvelocity.clarion.databasedrivers.