How to achieve the following query –
SELECT
CASE
WHEN COUNT(*) > 0 THEN
-- UPDATE operation
ELSE
-- INSERT operation
END AS [RESULT]
FROM
[TABLE_1]
WHERE
[CONDITION]
I am using SQL Server 2000.
Can someone please help me?
Use EXISTS not COUNT as per my answer
If you expect a very high proportion of updates, then why touch the table twice?
You can’t do the same for a very high proportion of INSERTs on SQL Server 2000: you need TRY/CATCH to handle duplicates as per my answer