SQLTeam.com | Weblogs | Forums

Return changed values


#1

Hi There,

I have situation, for example, employee file, which we get every month at month end including all employee list including hire, fire, active. I load all these month data into staging table respectively, for example, JanEmp, FebEmp.

EmplyeeID is the key and it is unique. I want to find out value changes between JanEmp and FebEmp, for example, John is active in Jan, but he is terminated in Feb, or transfer to other department.

essentially I want to say, for all employee ID in Feb who is also existed in Jan, return all change rows, is there query to do this?

Thanks


#2

example :

select *
from   JanEmp J inner join FebEmp F on J.EmplyeeID = F.EmplyeeID
where  J.EmpName <> F.EmpName