--The DEPT table has 4 records in it
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
30 SALES CHICAGO
20 RESEARCH DALLAS
40 OPERATIONS BOSTON
--The DEPT2 table has 2 records in it
DEPTNO DNAME LOC
20 RESEARCH DALLAS
40 OPERATIONS BOSTON
--After running this code, the DEPT2 table should be identical to DEPT
table
update m
set deptno = t.deptno
from dept2 m
inner join dept t
on m.deptno = t.deptno
insert into dept2 (deptno, .dname, loc)
select t.deptno, t.dname, t.loc
from dept t
left join dept2 m
on m.deptno = t.deptno
where m.deptno is null;
Please take a few minutes to provide feedback on the quality of service you received. The Department of Education values your feedback as a customer. Commissioner John L. Winn is committed to continuously assessing and improving the level and quality of services provided to you by Department staff. Simply use the link below. Thank you in advance for completing the survey.
http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]
MS Sql Server LazyDBA home page