在SQL 2005中使用此INSERT ON DUPLICATE KEY UPDATE QUERY更新 [英] update using this INSERT ON DUPLICATE KEY UPDATE QUERY in SQL 2005
本文介绍了在SQL 2005中使用此INSERT ON DUPLICATE KEY UPDATE QUERY更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
INSERT INTO addunitevent (EventID, UnitID) VALUES (2, 2) ON DUPLICATE KEY UPDATE UnitID= VALUES(UnitID);
下面显示的我的SQL语法显示错误消息,例如关键字"ON"附近的语法不正确"
My SQL syntax shown below it display the error message like " Incorrect Syntax near the Keyword ''ON''"
thanks in advance.
推荐答案
AFAIK,INSERT ... ON DUPLICATE ...仅在MySql中可用,而在MsSql中不可用-您必须先检查并执行根据需要插入或更新命令.抱歉!
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!
请参考以下链接以完成所需的操作,这些链接与mysql ON DUPLICATE KEY UPDATE相当:
http://msdn.microsoft.com/en-us/library/aa224818 [ ^ ]
http://msdn.microsoft.com/en-us/library/bb510625.aspx [ ^ ]
希望对您有所帮助:)
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 :)
MySQL具有在重复键上 [ ^ ].
检查MSSQL2005的此替代方法
http://stackoverflow.com/questions/2092510/sql-server-2005- bulk-update-or-insert [ ^ ]
MySQL has ON DUPLICATE KEY[^].
Check this alternative for MSSQL2005
http://stackoverflow.com/questions/2092510/sql-server-2005-bulk-update-or-insert[^]
这篇关于在SQL 2005中使用此INSERT ON DUPLICATE KEY UPDATE QUERY更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文