You can use the Update from statement to update tables of one table from another
for example you have a table Employee_old_table (employee_id,employee_name,employee_lname)
and e table employee_new_table (employee_id,employee_full_name,employee_first_name,employee_last_name)
to set the employee order.employee_full_name = employee.employee_name + ' ' + employee_lname
you can do this
update employee_full_name
set
employee_full_name = e.employee_name + ' ' + e.empoyee_lname,
employee_first_name = e.employee_name,
employee_last_name = e.employee_lname
from employee e
where e.employee_id = employee_id
instead of
update employee_full_name
set
employee_full_name = (select e.employee_name + ' ' + e.empoyee_lname from employee e where e.employee_id = employee_id),
employee_first_name = (select e.employee_name from employee e where e.employee_id = employee_id),
employee_last_name = (select e.employee_lname from employee e where e.employee_id = employee_id)
Monday, October 22, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment