Click here to Skip to main content
15,914,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
INSERT INTO addunitevent (EventID, UnitID) VALUES (2, 2) ON DUPLICATE KEY UPDATE UnitID= VALUES(UnitID);

My SQL syntax shown below it display the error message like " Incorrect Syntax near the Keyword 'ON'"
thanks in advance.
Posted
Updated 14-Jun-11 21:06pm
v2

AFAIK, INSERT...ON DUPLICATE... is only available in MySql, not MsSql - you will have to check first and do an insert or update command as necessary. Sorry!
 
Share this answer
 
Comments
[no name] 15-Jun-11 4:44am    
There are some tweaks to make this achive in MS SQL
refer these links to accomplish what you want, which are comparable with mysql ON DUPLICATE KEY UPDATE:

http://msdn.microsoft.com/en-us/library/aa224818[^]

http://msdn.microsoft.com/en-us/library/bb510625.aspx[^]

hope it helps :)
 
Share this answer
 
Comments
[no name] 15-Jun-11 4:44am    
looks good
 
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