From time to time my stored procedures looks like
create procedure handle_data @fk int ,@value varchar(10) as begin if exists (select * from my_table where id=@fk) begin update my_table set value=@value where id=@fk end else begin insert into my_table (fk,value) select @fk,@value end end
probably there is fault in design of app which calls this sproc.
Should I avoid making apps which do same sproc and methods for inserting new data and also updating old ones?
Is there better way to achieve updating or inserting data in one approach ?
I am using MSSQL2005/8.