my sql table:
CREATE TABLE [dbo].[PayrollParameter]
(
[PayrollParameterID] [CHAR](36) NOT NULL,
[Description] [NVARCHAR](50) NOT NULL,
[NumberOfDaysInMonth] [INT] NOT NULL,
[IsFixedDaysInMonth] [BIT] NOT NULL,
CONSTRAINT [PK_PayrollParameter] PRIMARY KEY CLUSTERED (
[PayrollParameterID] ASC )WITH (pad_index = OFF, statistics_norecompute =
OFF, ignore_dup_key = OFF, allow_row_locks = on, allow_page_locks = on) ON
[PRIMARY]
)
ON [PRIMARY]
GO
the database already contain records; I want to alter the table to set the default value of IsFixedDaysInMonth
to Checked if NumberOfDaysInMonth!=0
How can i do this?
CREATE DEFAULT needs a constant value as the default
Is an expression that contains only constant values (it cannot include the names of any columns or other database objects).
The only ways I know to do what you want would be to use a trigger or insert using a stored procedure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.