我還想問一下:
select @modify_YorN=field_A from table_A where field_B=@num_no
if @modify_YorN is not NULL
update table_A set field_C=’AA’ where field_B=@num_no
和
if exists(select * from table_A where field_B=@num_no)
begin
select @modify_YorN=返回值1
update table_A set field_C=’AA’ where field_B=@num_no
end
的區別很大嗎? [/B]
有區別的!
根據您的需求,必須用
if exists(select * from table_A where field_B=@num_no)
begin
select @modify_YorN=返回值1
update table_A set field_C=’AA’ where field_B=@num_no
end
ELSE
INSERT....
不過我真的不明白,我的field_A一定是非null值,但為什麼
select @modify_YorN=field_A from table_A where field_B=@num_no
和
if exists(select * from table_A where field_B=@num_no)
有區別?
我很菜,見笑了!