Friday, 24 August 2012

UPDATE table using Join statement

update a set sex=b.sex , age=b.age , dob=b.Dob , cellphone=b.CellPhone , emailid=EmailId1
--select *
from [MedallMart].[dbo].[TblTransactionData] a
inner join 
(select 
centerid,
patientID,
FirstName,
case when gender = 0 then 'Male' when gender = 1 then 'Female' else 'Others' end as Sex,
age ,
Dob,
CellPhone,
EmailId1
from tblpatient) as b on a.CenterID=b.CenterID and a.InPatientId=b.patientID and a.PatientName=b.FirstName

No comments:

Post a Comment