Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
たとえば、SQLサーバーで2つのレコードを交換したい
どうすればできますか?
SELECT *,CASE WHEN id=123 then 987 ELSE 123 END AS JoinId INTO #Temp FROM YourTable WHERE ID in (123,987) --swap values UPDATE y SET col1=t.col1 ,col2=t.col2 FROM YourTable y INNER JOIN #Temp t ON y.id =t.JoinId WHERE ID in (123,987)