本文介绍了检查计算列上的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我创建了此表
Hi all
I created this table
a | b | c | total | evaluation
1 | 2 | 3 | 6 |
5 | 2 | 8 | 15 |
--------------> 合计"列是求和(a + b + c)的结果
我想检查总计"列上的约束
如果合计= 12组评估=''完美''
否则将评估设置为弱"
--------------> " Total" is computed column is result for sum (a+b+c)
I want to check constraint on Total column
if total = 12 set evaluation =''Perfect''
else set evaluation = ''weak''
推荐答案
ALTER PROCEDURE dbo.ManageLaborEval
(
@a int,
@b int,
@c int
)
AS
BEGIN
Declare @sum bigint;
Set @sum = @a + @b + @c;
Declare @Evaluation NVARCHAR(30);
IF @sum = 12
BEGIN
Set @Evaluation = 'Perfect';
END
ELSE
BEGIN
Set @Evaluation = 'weak';
END
INSERT INTO Table1(a, b, c, total, evaluation) VALUES (@a,@b,@c, @sum, @Evaluation)
END
希望对您有帮助,
Azee ...
Hope it helps,
Azee...
这篇关于检查计算列上的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!