--BEGIN TRAN
--nb20071017 requried by dbUpdate

if not exists(select SysColumns.Name from sysobjects WITH (nolock) inner join SysColumns WITH (nolock) on SysColumns.Id = SysObjects.ID AND SysColumns.Name='FK_DepartmentNumber'
 where sysobjects.name = 'tabletypedepxtab')
  ALTER TABLE TableTypeDepXTab ADD FK_DepartmentNumber smallint NULL 
GO
UPDATE TableTypeDepXTab SET FK_DepartmentNumber = D.PK_Department
FROM TableTypeDepXTab, Departments AS D
WHERE TableTypeDepXTab.DepartmentNumber IS NOT NULL AND TableTypeDepXTab.DepartmentNumber = D.DepartmentNumber
AND TableTypeDepXTab.FK_DepartmentNumber IS NULL
--COMMIT TRAN	
