读书人

求 判判案句写法

发布时间: 2013-03-04 17:22:12 作者: rapoo

求 判断语句写法
create trigger T_aaa
on biao_1
for insert
AS

DECLARE @sl int,@mc nvarchar(20)
SELECT @mc=mc,@sl=sl FROM inserted

select id from sz_biao where ss_mc=@mc

判断假如 sz_biao 表记录等于空,执行插入,否则,更新
begin
INSERT INTO sz_biao (ss_sl, ss_mc)
VALUES (@sl,@mc)
end
Else
begin
UPDATE sz_biao
SET ss_sl=ss_sl+@sl where ss_mc=@mc
end

请教大侠,这判断语句如何写?

[解决办法]
if (select count(1) from sz_biao where ss_mc=@mc) >0

读书人网 >SQL Server

热点推荐