Possible Duplicate:
Solutions for INSERT OR UPDATE on SQL Server
Only inserting a row if it's not already there
My title pretty much explains what I'm trying to do, but I'll go into a little more detail. I'm creating a stored procedure when called it first checks to see if the row already exists (by comparing against two parameters) and if it does, it will update a specific column in the row and if the row doesn't exist already it will insert a new row into the table.
BEGIN
SELECT
(
CASE WHEN [Site] = @site and Plant = @plant
then
UPDATE [Status]
FROM Server_Status
WHERE [Site] = @site
ELSE
Insert into Server_Status(Name, [Path], [Site], Plant, [Status])
Values (@name, @path, @site, @plant, @status)
end
)
FROM Server_Status
END
Is what I have so far, but doesn't work (obviously). Does anyone with more SQL knowledge than I have any suggestions?
-J