I am creating a table that has default constraint for a column that has default value is other column value
This is my table script:
CREATE TABLE [ADMIN].[TblUserType]
(
[FunctionId] [tinyint] NOT NULL,
[UserTpyeId] [int] IDENTITY(1,1) NOT NULL,
[Description] [nvarchar](50) NOT NULL,
[ParentId] [int] NOT NULL,
[CreatedBy] [int] NOT NULL,
[UpdatedBy] [int] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[Status] [char](1) NOT NULL
)
Now I am altering table using this script
ALTER TABLE ADMIN.TblUserType
ADD CONSTRAINT De_Value DEFAULT UserTpyeId FOR (ParentId)
I am getting error like this
Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
But I need to add that column (UserTpyeId) value has default value for this column (ParentId)
How to do this?
Thank you