How to change the STF.ID value of a STF record


Step 1: Verify the new ID is not in use

SELECT * FROM STF WHERE ID = 123


Step 2: Prepare the script

If the STF.ID is not in use, populate the variables in the script below

  • Set the current ID (@ID)
  • Set the new ID (@HRID)
DECLARE @ID AS INT
DECLARE @HRID AS INT

SET @ID = 123
SET @HRID = 321

--SELECT * FROM STF WHERE ID = @HRID
--SELECT * FROM STF WHERE ID = @ID --Check to see if ID exists
UPDATE STF SET ID = @HRID WHERE ID = @ID --update ID
UPDATE UGN SET SID = @HRID WHERE SID = @ID
UPDATE SBH SET ID4 = @HRID WHERE ID4 = @ID
UPDATE ADS SET SRF = @HRID WHERE SRF = @ID
UPDATE ATR SET ID = @HRID WHERE ID = @ID
UPDATE CAT SET SID = @HRID WHERE SID = @ID
UPDATE CSE SET SI = @HRID WHERE SI = @ID
UPDATE CSV SET SI = @HRID WHERE SI = @ID
UPDATE DIS SET SID = @HRID WHERE SID = @ID
UPDATE DRA SET ID = @HRID WHERE ID = @ID
UPDATE DVR SET TID = @HRID WHERE TID = @ID
UPDATE GBK SET SID = @HRID WHERE SID = @ID
UPDATE GRD SET SID = @HRID WHERE SID = @ID
UPDATE HIS SET SID = @HRID WHERE SID = @ID
UPDATE PRI SET SID = @HRID WHERE SID = @ID
UPDATE RFI SET SID = @HRID WHERE SID = @ID
UPDATE SCH SET SID = @HRID WHERE SID = @ID
UPDATE SCN SET SID = @HRID WHERE SID = @ID
UPDATE SGS SET ID = @HRID WHERE ID = @ID
UPDATE SPC SET ID = @HRID WHERE ID = @ID
UPDATE SSE SET ID = @HRID WHERE ID = @ID
UPDATE SSM SET ID = @HRID WHERE ID = @ID
UPDATE STA SET ID = @HRID WHERE ID = @ID
UPDATE STC SET ID = @HRID WHERE ID = @ID
UPDATE STE SET ID = @HRID WHERE ID = @ID
UPDATE STH SET ID = @HRID WHERE ID = @ID
UPDATE STJ SET ID = @HRID WHERE ID = @ID
UPDATE STU SET CNS = @HRID WHERE CNS = @ID
UPDATE TCH SET ID = @HRID WHERE ID = @ID
UPDATE TCH SET ID2 = @HRID WHERE ID2 = @ID
UPDATE TCH SET ID3 = @HRID WHERE ID3 = @ID
UPDATE TFL SET SID = @HRID WHERE SID = @ID
UPDATE TSD SET SID = @HRID WHERE SID = @ID
UPDATE TSO SET SID = @HRID WHERE SID = @ID
UPDATE UGN SET SID = @HRID WHERE SID = @ID
UPDATE GBB SET SID = @HRID WHERE SID = @ID
UPDATE GRH SET SID = @HRID WHERE SID = @ID
--UPDATE SBH SET ID = @HRID WHERE ID = @ID
UPDATE SBH SET ID2 = @HRID WHERE ID2 = @ID
UPDATE SBH SET ID3 = @HRID WHERE ID3 = @ID


Step 3: Run the Script

Once the variables have been set, run the script