Incorrect syntax near the keyword 'ON' – SQL Server 2019


Can anyone tell me why the following syntax is resulting in error? I would like to update the ip address field with dynamic ip addresses if a current record exists with a matching primary key.

INSERT INTO Overview([Computername], [IpAddress]) VALUES('test', '') ON DUPLICATE KEY UPDATE Overview set IpAddress = '';

>Solution :

There is no "ON DUPLICATE KEY" allowed in MS SQL Server. This syntax is only allowed on MySQL.

Leave a Reply Cancel reply