Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update UNION value

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2007-05-01 : 01:51:47
UPDATE tbl_emp_contact
SET email = ?,phone =?
WHERE loan_number='021067367'

Iam trying to update the union value from below to the update statement.There will be only one value after the union.Either a value or a NULL value.

SELECT email_addr,phone_number
FROM staging.dbo.tbl_emp
WHERE loan_number='021067367'
UNION
SELECT email_addr,phone_number
FROM archive_reporting.dbo.tbl_emp
WHERE loan_number='021067367'


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-01 : 02:09:05
[code]
update u
set email = a.email_addr,
phone = a.phone_number
from tbl_emp_contact u
inner join
(
SELECT loan_number, email_addr,phone_number
FROM staging.dbo.tbl_emp
UNION
SELECT loan_number, email_addr,phone_number
FROM archive_reporting.dbo.tbl_emp
) a
ON u.loan_number = a.loan_number
WHERE u.loan_number = '021067367'
[/code]


KH

Go to Top of Page

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2007-05-01 : 02:22:40
Thanks a lot
Go to Top of Page
   

- Advertisement -