i wanted to update the contactperson if email exists.i have wrtten the following query to update it in SP.
There are many other fields.What happeniing is that: if the contactperson name say is Alex and i wanted to update it to Alexa,it is not getting change.
update cmp
set cmp.companyname=case when cmp.companyname='' or cmp.companyname=null then dupl.companyname else cmp.companyname end ,
cmp.website= case when cmp.website='' OR cmp.website IS NULL then dupl.website else cmp.website end ,
cmp.contactperson= case when cmp.contactperson='' OR cmp.contactperson IS NULL then dupl.contactperson else cmp.contactperson end,
cmp.country = case when cmp.country=1 OR cmp.country IS NULL then dupl.country else cmp.country end,
cmp.telphone=case when cmp.telphone='' OR cmp.telphone IS NULL then dupl.telphone else cmp.telphone end,cmp.mobile= case when cmp.mobile='' OR cmp.mobile IS NULL then dupl.mobile else cmp.mobile end ,
cmp.fax= case when cmp.fax='' OR cmp.fax IS NULL then dupl.fax else cmp.fax end, cmp.region= case when cmp.region=2 OR cmp.region IS NULL then dupl.region else cmp.region end,
cmp.address= case when cmp.address='' OR cmp.address IS NULL then dupl.address else cmp.address end,cmp.designation= case when cmp.designation='' OR cmp.designation IS NULL then dupl.designation else cmp.designation end,
cmp.products= case when cmp.products='' OR cmp.products IS NULL then dupl.products else cmp.products end
from companyinfo cmp
inner join #DuplTempTable dupl on cmp.ID=dupl.ID
hi sir...cmp is companyinfo .....email field is there in emailinfo table...
comapanyinfo: ID,Dataid,companyname
emailinfo: ID,Dataid,email
how to write it in a select query?