If I get what you are asking.
I believe the Lead/Lag analytic functions would be what you are looking for.
But seeing you are on SQL-server-2008R2, that will not help you out and it is a feature in SQLServer2012.
So here is a possible way of doing a lead/lag in SQL-server-2008R2 for your scenario:
with Emp as (
select
1305 empcode,
'0013' dsg_code,
'DIVISION SALESMANAGER' dsg_name,
convert(datetime, '2011 apr 30 00:00:00') date,
2011 PAY_YEAR
union all select 1305, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2011 nov 30 00:00:00'), 2011
union all select 1305, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2012 jan 31 00:00:00'), 2012
union all select 1305, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2013 jan 31 00:00:00'), 2013
union all select 1305, '0013', 'DIVISION SALES MANAGER', convert(datetime, '2013 mar 31 00:00:00'), 2013
union all select 1305, '0013', 'DIVISION SALES MANAGER', convert(datetime, '2014 jan 31 00:00:00'), 2014
union all select 1305, '00211', 'DIVISIONAL MANAGER', convert(datetime, '2014 aug 31 00:00:00'), 2014
union all select 1305, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2015 jan 31 00:00:00'), 2015
union all select 1355, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2011 nov 30 00:00:00'), 2011
union all select 1355, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2012 jan 31 00:00:00'), 2012
union all select 1355, '00104', 'REGIONAL SALES MANAGER', convert(datetime, '2013 jan 31 00:00:00'), 2013
), EmpRowId as (
select
row_number() over(partition by Emp.empcode order by Emp.empcode, Emp.date) rowid
, *
from Emp
)
, EmpLag as (
select
e.*,
isnull(Lag.dsg_code, '') Lagdsg_code,
isnull(Lag.dsg_name, '') Lagdsg_name
from EmpRowId e
left join EmpRowId Lag
on e.empcode = Lag.empcode
and e.rowid = Lag.rowid + 1
)
select
*
from EmpLag
where dsg_code <> Lagdsg_code
order by
empcode,
date
;
Hope that helps you out.
Here is a link for the Lead/Lag example:
http://www.rafael-salas.com/2008/05/t-sql-lead-and-lag-functions.html[
^]