Spring Jdbc query execution
问题 Does anyone know how what Spring Jdbc template method I could use to execute this 'upsert' or an alternative approach that would also perform the operations in one database call? UPDATE jasper_report SET Uri = 'update' WHERE ReportId = 99; IF @@ROWCOUNT = 0 AND Exists(Select 1 FROM report Where Id = 99) BEGIN INSERT INTO jasper_report (ReportId, Uri) VALUES (99, 'insert') END; 回答1: Turns out I was close but forget a step. I had to change the query itself to: BEGIN UPDATE jasper_report SET Uri