Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends


I have 2 tables as shown below


tblDetails:

genericName value

a 0
a 0
b 0
b 0
c 0
d 0


tblMaster:

GendericName Value

a 1
b 0
c 1
d 1


After Inserting values I will get tblDetails as shown above.
But I would like to update the value column according to the tblMaster table.

I would Like to get the final result as

tblDetails:
genericName value

a 1
a 1
b 0
b 0
c 1
d 1



Please help me...

Thank Youu... :)
Posted
Comments
_Asif_ 1-Sep-14 8:25am    
Where is your Table insertion code?
SubhashRokzzz 1-Sep-14 8:28am    
create create procedure sp_savDetails
(
@gname varcjar(20),
@value int
)
as
begin
insert into tblDetails(genericName,value) values(@gname,@value)
end
_Asif_ 1-Sep-14 8:39am    
why can't you provide tblMaster->a value (1) in @value parameter? :)
SubhashRokzzz 1-Sep-14 8:41am    
I can not give any value manually...bcoaz I update the table from very large excel sheet

Hi,

Check this...

SQL
update tblDetails 
set
tblDetails.value=tblMaster.Value
from
tblMaster
where
tblDetails.genericName=tblMaster.genericName


Now You can check...
SQL
Select * from tblDetails


Hope this will help you.

Cheers
 
Share this answer
 
Comments
SubhashRokzzz 3-Sep-14 2:01am    
Thank you Magic Wonder.... u r jus Osm.. :D
Magic Wonder 3-Sep-14 3:10am    
your welcome ...thnx
Please check once this :


SQL
create procedure sp_savDetails
(
@gname varchar(20)
)
as
begin
insert into tblDetails select @gname ,value from tblMaster where genericName=@gname
end
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900