
	IF OBJECT_ID('NET_SEL_APARTAMENTO') IS NOT NULL
		DROP PROC NET_SEL_APARTAMENTO

	GO
		CREATE PROC NET_SEL_APARTAMENTO
	(
			   @pCodApartamento	int
				,@pInn	nchar(100)
				,@pOut	nchar(100)
				,@pApto	nchar(100)
				,@pAptoNumero	nchar(30)
				,@pAptoAla	nchar(100)
				,@pAptoType	int
				,@pStatus	int
			  ,@pOrder VARCHAR(50) =  NULL 

	)
	AS 
		
		BEGIN
			SET NOCOUNT ON
			
					SELECT 
									CodApartamento
									,Inn
									,Out
									,Rn
									,Est
									,Seq
									,Apto
									,Cama
									,AptoNumero
									,AptoAla
									,Piso
									,AptoType
									,Diaria
									,ISS
									,Extras
									,Estacionamento
									,Status
									,CodUsuario
									,DataCadastro
									,DataUpdate
		FROM 
						NET_APARTAMENTO
WHERE     
					((CodApartamento = @pCodApartamento) Or (@pCodApartamento IS NULL OR @pCodApartamento  = 0))
			And ((Out = @pOut) Or (@pOut IS NULL OR @pOut= ''))
			And ((Inn	 = @pInn	) Or (@pInn	IS NULL OR @pInn	= ''))
			And ((Apto	 = @pApto	) Or (@pApto	IS NULL OR @pApto	= ''))
			And ((AptoNumero	 = @pAptoNumero	) Or (@pAptoNumero	IS NULL OR @pAptoNumero	= ''))
			And ((Inn	 = @pAptoAla) Or (@pAptoAla IS NULL OR @pAptoAla= ''))
			And ((AptoType= @pAptoType) Or (@pAptoType IS NULL OR @pAptoType= 0))


			
			And ((Status = @pStatus) Or (@pStatus IS NULL OR @pStatus  = 3))
			

	SET NOCOUNT OFF 
	END 

