Conditionally insert otherwise update based on select result
Using SQL Server, How can I create a CASE statement depending on the value of a Select Statement with a parameter?
I need to insert data if the ID doesn't exist (NULL) in table Products and if it exists I need to update the data.
I have the below CASE statement query but the syntax is wrong:
Select CASE WHEN (select ID from Products where ProdID = @ProdID) = NULL
then
(INSERT INTO Table...)
Else
(Update Table...)
END as Prods
FROM Products