开发者

tsql default value dpends on other field

is something like that possible ?

CREATE TABLE [dbo].[T_ALERT](
    [id] [bigint] NOT NULL IDENTITY(1,1),
    [times] [int] NOT NULL DEFAULT(1),
    [times left] [int] DEFAULT(ti开发者_如何学JAVAmes), --Here times_left get times as default
 CONSTRAINT [PK_T_ALERT] PRIMARY KEY CLUSTERED 
(
    [user_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


No, but you can accomplish the same thing by making the column TimesUsed (or whatever is appropriate for your usage) and defaulting it to 0, then just doing subtraction in your query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜