How do update and insert data in one table using the data in another table

I have two tables prod1 and prod2 having same fields (pid,pname,pprice,pcode). Have some data in prod1 table like below

Pid     Pname    Pprice  Pcode
---     -----    ------  -----
1       Aaaaa    500     A-1
2       Bbbbb    1000    B-1
3       Ccccc    1500    C-1

And have data in prod2 table like below

Pid     Pname    Pprice  Pcode
---     -----    ------  -----
1       Aaaaa    5000    A-1
2       Bbbbb    5000    B-1
3       Ccccc    1500    C-2
4       Ddddd    2000    D-1
5       Eeeee    500     E-1

I need to update prod1 table using prod2 table

If prid1.pid=prod2.pid
Else
Insert the data into prod1 from prod2

Final aim is to store prod2 data in prod1 without delete in prod1 Help me to solve I tried cases and while etc

Answers


Finally Solved My Problem ..........................

update prod1 set pname=b.pname, pprice=b.pprice, pcode=b.pcode from prod2 b,prod1 a where a.pid=b.pid

select * from prod1 insert into prod1 select * from prod2 b where b.pid not in(select pid from prod1)

Thanks


Need Your Help

Built-In Character Casing functions in .Net

c# .net string

Are there any built-in functions in .Net that allow to capitalize strings, or handling proper casing? I know there are some somewhere in the Microsoft.VB namespace, but I want to avoid those if pos...