INSERT INTO asurnet.dbo.DEPARTAMENTOS (
		DPT_Id,
		DPT_Nombre,
		DPT_FC,
		USR_ID_FC,
		DPT_FM,
		USR_ID_FM,
		USR_ID
	)
SELECT DPT_Id,
	DPT_Nombre,
	DPT_FC,
	B.IDTSS AS USR_ID_FC,
	DPT_FM,
	C.IDTSS AS USR_ID_FM,
	D.IDTSS AS USR_ID
FROM vsegbas.dbo.DEPARTAMENTOS A
	LEFT JOIN (
		SELECT *
		FROM tssseg0001.dbo.IDTraspasos
		WHERE TableID = 'Usuarios'
	) B ON A.USR_ID_FC = B.IDTras
	LEFT JOIN (
		SELECT *
		FROM tssseg0001.dbo.IDTraspasos
		WHERE TableID = 'Usuarios'
	) C ON A.USR_ID_FM = C.IDTras
	LEFT JOIN (
		SELECT *
		FROM tssseg0001.dbo.IDTraspasos
		WHERE TableID = 'Usuarios'
	) D ON A.USR_ID = D.IDTras

DELETE FROM asurnet.dbo.usrdpt
INSERT INTO asurnet.dbo.usrdpt (USR_Id, DPT_Id)
SELECT B.IDTSS AS USR_Id,
	DPT_Id
FROM vsegbas.dbo.usrdpt A
	INNER JOIN (
		SELECT *
		FROM tssseg0001.dbo.IDTraspasos
		WHERE TableID = 'Usuarios'
	) B ON A.USR_ID = B.IDTras