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

Advertisements

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', '127.0.0.1') ON DUPLICATE KEY UPDATE Overview set IpAddress = '127.0.0.1';

>Solution :

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

Leave a Reply Cancel reply