批量插入,批量更新
--批量插入(事先查询相对应的字段到临时表#temp1) SELECT ID,Name,Status INTO #temp1 FROM dbo.Doctor d WHERE d.ID NOT IN (SELECT ID FROM dbo.UP_Doctor) INSERT INTO dbo.UP_Doctor ( ID, Name, Status ) SELECT * FROM #temp1 DROP TABLE #temp1; --批量更新(事先查询相对应的字段到临时表#temp2) SELECT ID,Name,Status INTO #temp2 FROM dbo.Doctor UPDATE dbo.UP_Doctor SET Name=#temp2.Name, Status = #temp2.Status FROM #temp2 WHERE dbo.UP_Doctor.ID = #temp2.ID DROP TABLE #temp2;