Created
May 5, 2010 18:21
-
-
Save srkirkland/391220 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @el table | |
( | |
new_id int identity(1,1), | |
old_id int | |
) | |
-- transfer the information from the time/expense sheets | |
begin transaction | |
begin try | |
-- enable identity insert | |
set identity_insert EL.dbo.ActionTypes on | |
set identity_insert EL.dbo.Committee on | |
set identity_insert EL.dbo.Step on | |
set identity_insert EL.dbo.EligibilityList on | |
-- migrate the lookup tables | |
insert into EL.dbo.ActionTypes (ID, Name, Inactive) | |
select ActionTypeID, Name, IsActive | |
from EligibilityList.dbo.ActionTypes | |
insert into EL.dbo.Committee(ID, Name, Inactive) | |
select ID, Committee, IsActive | |
from EligibilityList.dbo.Committee | |
insert into EL.dbo.Step (ID, Name, Inactive) | |
select StepID, Step, IsActive | |
from EligibilityList.dbo.Step | |
-- migrate the primary eligibility table | |
INSERT INTO [EL].[dbo].[EligibilityList] | |
(AppointmentID, [EmployeeID] ,[DIST_DEPT_CODE] ,[FISCode] ,[DADAssociateDeanID] ,[DADKerb] | |
,[AnalystID] ,[AnalystKerb] | |
,[ActionID] ,[YearsAtRank] ,[YearsAtStep] ,[AppointmentPercent] | |
,[CommitteeID] ,[TITLE_CODE] ,[CurrentStep] ,[CurrentBlankTitle] | |
,[ProposedTitleCode] ,[ProposedStep] ,[ProposedBlankTitle] | |
,[YearsAccelerated] ,[YearsDecelerated] | |
,[Defer] ,[DateDue] ,[DateToCommittee] ,[DateCommitteeReceived] | |
,[DateEffective] ,[Comment] ,[FinalAction] ,[TPC_PAY_REP_CODE] | |
,[APPT_NUM] ,[LastUpdated] ,[ProposedAppointmentPercent]) | |
select AppointmentID, EmployeeID, el.DIST_DEPT_CODE, dc.FISCode, el.DADAssociateDeanID, dad.DADKerb | |
, el.AnalystID, an.AnalystKerb | |
, el.ActionID, el.YearsAtRank, el.YearsAtStep, el.AppointmentPercent | |
, el.CommitteeID, el.TITLE_CODE, el.CurrentStep, el.CurrentBlankTitle | |
, el.ProposedTitleCode, el.ProposedStep, el.ProposedBlankTitle | |
, el.YearsAccelerated, el.YearsDecelerated | |
, el.Defer, el.DateDue, el.DateToCommittee, el.DateCommitteeReceived | |
, el.DateEffective, el.Comment, el.FinalAction, el.TPC_PAY_REP_CODE | |
, el.APPT_NUM, el.LastUpdated, el.ProposedAppointmentPercent | |
from EligibilityList.dbo.EligibilityList el | |
left outer join EligibilityList.dbo.DepartmentCode dc on el.DIST_DEPT_CODE = dc.HOME_DEPT_NO | |
left outer join EligibilityList.dbo.DADAssociateDeans dad on el.DADAssociateDeanID = dad.DADAssociateDeanID | |
left outer join EligibilityList.dbo.Analysts an on el.AnalystID = an.AnalystID | |
set identity_insert EL.dbo.EligibilityList off | |
-- insert the temporary eligibility lists | |
INSERT INTO [EL].[dbo].[EligibilityList] | |
([EmployeeID] ,[DIST_DEPT_CODE] ,[FISCode] ,[DADAssociateDeanID] ,[DADKerb] | |
,[AnalystID] ,[AnalystKerb] | |
,[ActionID] ,[YearsAtRank] ,[YearsAtStep] ,[AppointmentPercent] | |
,[CommitteeID] ,[TITLE_CODE] ,[CurrentStep] ,[CurrentBlankTitle] | |
,[ProposedTitleCode] ,[ProposedStep] ,[ProposedBlankTitle] | |
,[YearsAccelerated] ,[YearsDecelerated] | |
,[Defer] ,[DateDue] ,[DateToCommittee] ,[DateCommitteeReceived] | |
,[DateEffective] ,[Comment] ,[FinalAction] ,[TPC_PAY_REP_CODE] | |
,[APPT_NUM] ,[ProposedAppointmentPercent], [OriginalApptID]) | |
select EmployeeID, el.DIST_DEPT_CODE, dc.FISCode, el.DADAssociateDeanID, dad.DADKerb | |
, el.AnalystID, an.AnalystKerb | |
, el.ActionID, el.YearsAtRank, el.YearsAtStep, el.AppointmentPercent | |
, el.CommitteeID, el.TITLE_CODE, el.CurrentStep, el.CurrentBlankTitle | |
, el.ProposedTitleCode, el.ProposedStep, el.ProposedBlankTitle | |
, el.YearsAccelerated, el.YearsDecelerated | |
, el.Defer, el.DateDue, el.DateToCommittee, el.DateCommitteeReceived | |
, el.DateEffective, el.Comment, el.FinalAction, el.TPC_PAY_REP_CODE | |
, el.APPT_NUM, el.ProposedAppointmentPercent, AppointmentID | |
from EligibilityList.dbo.tempEligibilityList el | |
left outer join EligibilityList.dbo.DepartmentCode dc on el.DIST_DEPT_CODE = dc.HOME_DEPT_NO | |
left outer join EligibilityList.dbo.DADAssociateDeans dad on el.DADAssociateDeanID = dad.DADAssociateDeanID | |
left outer join EligibilityList.dbo.Analysts an on el.AnalystID = an.AnalystID | |
-- disable the identity insert | |
set identity_insert EL.dbo.ActionTypes off | |
set identity_insert EL.dbo.Committee off | |
set identity_insert EL.dbo.Step off | |
commit transaction | |
end try | |
begin catch | |
rollback transaction | |
set identity_insert EL.dbo.ActionTypes off | |
set identity_insert EL.dbo.Committee off | |
set identity_insert EL.dbo.Step off | |
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int | |
SELECT @ErrMsg = ERROR_MESSAGE(), | |
@ErrSeverity = ERROR_SEVERITY() | |
RAISERROR(@ErrMsg, @ErrSeverity, 1) | |
end catch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment