insert and update in one stored proc(but updating firing twice)

Giganews Newsgroups
Subject: insert and update in one stored proc(but updating firing twice)
Posted by:  rote (naijacod…@hotmail.com)
Date: Tue, 25 Nov 2008

I have  and update and insert statement in a stored proc like so:

If Exists (Select * From table WHERE a=@a and b=@b)
update table
set
a= @a,
b=@b
from  table where
a=@a and b=@b

Insert into c
a,b
select
@a,@b
from table where
a=@a and b=@b

Why am i getting 2 records inserted at the same time to table c.
Any ideas.. Guess i'm blind
I simply have an insert and update statement in  a stored proc.
I want to update and then insert the record that was updated into another
table as you can see in queries
It actually works but the problem is i get the same record update twice.
Thanks

Replies