/*
  Created by Kent Johansen February 2011

  Add ChangeDate to primary key. Requirement# 800. Identity for Course Certificate
*/
UPDATE IdentityFields SET ChangeDate = GETDATE() WHERE ChangeDate IS NULL

IF EXISTS (SELECT name FROM SysIndexes(NOLOCK) WHERE name = 'PK_IdentityFields')
  ALTER TABLE IdentityFields DROP CONSTRAINT PK_IdentityFields
   
ALTER TABLE IdentityFields ALTER COLUMN ChangeDate SMALLDATETIME NOT NULL
GO
  
ALTER TABLE IdentityFields WITH NOCHECK 
ADD CONSTRAINT PK_IdentityFields PRIMARY KEY CLUSTERED 
(
  [DBTableName] ASC,
  [HotelCustomerNumber] ASC,
  [FkDepartment] ASC,
  [ChangeDate] ASC
)