Monday, 8 October 2012
#27. With di Sql Server


WITH n(IdCovJob, idemp, startdate, enddate) AS
(
select idcovjob, idemp, startdate, enddate
from MCovjobemployee --where IdEmp='1576'
union all
SELECT x.idCovJob, n.idemp, x.activeddate, x.enddate
FROM MCoverJob x WITH (NOLOCK), n
WHERE n.IdCovJob = x.IdCovJobPar
)
insert into TempEmpCovjob (IdCovJob, idemp, startdate, enddate)
select * from (
select * from n
)x
(
select idcovjob, idemp, startdate, enddate
from MCovjobemployee --where IdEmp='1576'
union all
SELECT x.idCovJob, n.idemp, x.activeddate, x.enddate
FROM MCoverJob x WITH (NOLOCK), n
WHERE n.IdCovJob = x.IdCovJobPar
)
insert into TempEmpCovjob (IdCovJob, idemp, startdate, enddate)
select * from (
select * from n
)x
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment