Click here to Skip to main content
15,908,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

How can i run this sql code?
C#
Update Urun set id=2 where id=1;
Update Urun set name='Ron' where id=3;


When i try to run this code i got error

What I have tried:

run this code separatly and it work correctly
Posted
Updated 21-Mar-17 22:25pm
Comments
Karthik_Mahalingam 21-Mar-17 9:18am    
what is the error message,
I have tried, it works

You can use case statement

Update Urun Set id=(case when id=1 Then 2 else id end),name =(case when id=3 then 'Ron' else name end)
Where id in(1,3)
 
Share this answer
 
Update Urun
Set id=(case when id=1 Then 2 else id end),
name =(case when id=3 then 'Ron' else name end)
Where id in(1,3)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900