Conditionally insert otherwise update based on select result
10:33 22 Dec 2014

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
sql sql-server switch-statement