SQL判断是否存在该数据 有则更新,没有则插入
Update
dbo.PartOpr
Set
字段=值
-- 存在記錄才更新
Where
OperationDesc=@OperationDesc
and
TopVersion=@TopVersion
and
DrawNum=@DrawNum
and
TopPartNum=@TopPartNum
and
[Version]=@Version
Insert
into
dbo.PartOpr(字段)
Select
字段
-- 不存在記錄才插入
Where
Not
exists(
select
1
from
dbo.PartOpr
Where
OperationDesc=@OperationDesc
and
TopVersion=@TopVersion
and
DrawNum=@DrawNum
and
TopPartNum=@TopPartNum
and
[Version]=@Version
)