0

I'm getting this error when I'm trying to execute query in SQL Server using terminal.

Query

REPLACE INTO [wine].[Spirits] (skuId, name, packageDescription, packageValue, price) 
VALUES ('1', '1a', '2b', 'd', '12.00')

Error

Msg 156, Level 15, State 1, Server localhost, Line 1
Incorrect syntax near the keyword 'INTO'

Additional info: insert query is working properly

INSERT INTO [wine].[Spirits] (skuId, name, packageDescription, packageValue, price) 
VALUES ('1', 'a', 'b', 'd', '12.00') 

Can anyone point out what's I'm doing wrong here?

I know this sounds like very basic question in SQL Server, but sorry I'm new to this language.

I'm not sure whether REPLACE is available in SQL Server.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
newbie
  • 128
  • 2
  • 15
  • 2
    `REPLACE` is a function, not an operator; what are you expecting it to do here? – Thom A Nov 13 '22 at 08:57
  • If the skuId exists, I want the row to updated, otherwise insert as new row. that's what REPLACE does in MySQL, MariaDB. I don't know whether it's something possible to do in MSSQL. https://dev.mysql.com/doc/refman/8.0/en/replace.html – newbie Nov 13 '22 at 09:01
  • 1
    You want a `MERGE` or "Upsert". – Thom A Nov 13 '22 at 09:05
  • seems REPLACE INTO is not a feature in MSSQL according to that answers. I will go with if condition check method. anyway thanks for the help. – newbie Nov 13 '22 at 09:20

0 Answers0