View Single Post
  #4 (permalink)  
Old 05-07-2006, 11:20 PM
Rob137
 
Posts: n/a
Default T-SQL answer. Re: Insert or update a record if it already exists?

How about this:
[sql]
if (exists (select * from AA_TestTable as t1
where t1.ord_num = 'FFF'))
begin
update AA_TestTable
set ord_qty = 999
where ord_num = 'FFF'
end
else
begin
insert into AA_TestTable (ord_num, top_assy, ord_qty)
values('GGG', 'XYZ', 567)
end
[/sql]
Reply With Quote