Is there a way to do this in one instruction :
update mytable set datafield=datavalue where keyfield=keyvalue
if @@rowcount=0
insert into mytable (keyfield, datafield) values (keyvalue, datavalue)
In other words : for a given key update a row and if it doesn't exist insert a row with that key/data