SQL判断是否存在该数据 有则更新,没有则插入
Update dbo.PartOpr Set 字段=值-- 存在記錄才更新Where OperationDesc=@OperationDesc and TopVersion=@TopVersion and DrawNum=@DrawNum and TopPartNum=@TopPartNum and [Version]=@VersionInsert 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 )

浙公网安备 33010602011771号