In SQL Server, can you create a default constraint for a column using the result or return value from a Stored procedure, and if so how?
So I am thinking of something along the lines of this, but with valid SQL.
ALTER TABLE [dbo].[MyTable]
ADD CONSTRAINT [DF_MyTable_MyColumn]
DEFAULT (EXEC [dbo].[GetNextNumber]) FOR [MyColumn]
GO
My reason for this is I have a table which has the sole responsibility of providing the next number to use, and a table which the default value must use this next number every time a new record is entered.
IDENTITY
or aSEQUENCE
?