IF EXISTS(SELECT * FROM sys.objects where name = 'stp_Select_Usuario_byUser')
BEGIN 
	DROP PROCEDURE stp_Select_Usuario_byUser
END 
GO 


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE stp_Select_Usuario_byUser
	-- Add the parameters for the stored procedure here	
	@vchUser varchar(200) 
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
    Select 
		USU.intUsuarioId, 
		USU.vchUsuario,
		USU.vchEmail, 
		USU.vchContrasena, 
		USU.vchTelefono, 
		USU.vchMovil, 
		USU.bitActivo, 
		USU.datFalta,
		USU.bitAdministrador
		,USG.vchNombre			
		,USG.vchApellidoPaterno	
		,USG.vchApellidoMaterno	
		,USG.vchFechaNacimiento	
		,USG.vchSexo			
		,USG.vchCodigoPostal	
		,USG.vchDireccion		
		,USG.vchColonia			
		,USG.vchCiudad			
		,USG.vchEstado		
		,USG.vchPais		
	From 
		UserQC.tbl_mst_Usuarios USU
	Left Join 
		tbl_det_UsuariosGenerales USG
		ON USU.intUsuarioId = USG.intUsuarioId
	Where 
		vchUsuario = @vchUser
	order by 
		datFalta desc
    
  		 
END 
GO