modify value on a table with some conditions
===

i need some help with mssql, i dont know anything from mssql query but i know some programing.
i have 2 tables, TableA and TableB each one has 2 columns 
ColumnA1, ColumnA2, ColumnB1 and ColumnB2

Something like this
create table DB.dbo.TableA
(ColumnA1 varchar(10),
ColumnA2 int)
create table DB.dbo.TableB
(ColumnB1 varchar(10),
ColumnB2 int)

and i need to check if exist a row in TableA where ColumnA2>0
if so, then,
IF any of those possible rows also exists in ColumnB1,
update ColumnB2=ColumnB2+ColumnA2 and set ColumnA2=0
ELSE
insert a new row in TableB with ColumnB1=ColumnA1 and ColumnB2=ColumnA1 and set ColumnA2=0

i dont even know where to start, i tryed to explain it the best way i could
thanks in advance ;)