IF OBJECT_ID('V_SINCRONIZAR_USUARIO_DROGRASMIL') IS NOT NULL
BEGIN
	DROP VIEW V_SINCRONIZAR_USUARIO_DROGRASMIL
END

GO

CREATE VIEW V_SINCRONIZAR_USUARIO_DROGRASMIL
AS
SELECT	
	FP_FUNC.CD_FUN,
	FP_FUNC.MATRIC,
	FP_FUNC.NM_FUN,
	FP_CARGO.CD_CARGO AS TP_CARGO,
	ISNULL(GLB_USU.SENHA,'') AS SENHA,
	ISNULL(GLB_USU.CD_USU,0) AS IS_VEND,
	GLB_USU_FILIAL.CD_FILIAL

FROM FP_FUNC INNER JOIN FP_CARGO ON 
	FP_FUNC.CD_EMP = FP_CARGO.CD_EMP AND 
	FP_FUNC.CD_CARGO = FP_CARGO.CD_CARGO 
	
	INNER JOIN GLB_USU ON 
	FP_FUNC.CD_FUNC_USU = GLB_USU.CD_USU

	INNER JOIN GLB_USU_FILIAL ON 
	GLB_USU_FILIAL.CD_USU=GLB_USU.CD_USU 


WHERE (FP_FUNC.STS_FUN = 0)




