---
title: "一句话解决更新和插入的问题"
author: "bestsaler"
date: "2010-08-27T11:19:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2010-08-27T11:19:00Z"
id: 759088
url: "https://bestsaler.iteye.com/blog/759088"
---

一句话解决更新和插入的问题

if exists(select 1 from Pat\_ResultScores where SID=:SID) update Pat\_ResultScores set Scores=:Scores,UserY=:UserY,UserP=:UserP where SID=:SID else insert into Pat\_ResultScores(SID,Scores,UserY,UserP) values(:SID,:Scores,:UserY,:UserP)