
GO
/****** Objeto:  StoredProcedure [dbo].[sel_cat_catalogo_bodegas_itemDocumento]    Fecha de la secuencia de comandos: 07/08/2013 11:55:16 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[sel_cat_catalogo_bodegas_itemDocumento]
    @p_idDocumento as int
AS
BEGIN
SELECT [doc_itemDocumento].id as id_item,
       [doc_itemDocumento].id_catalogo as id_catalogo,
       [doc_itemDocumento].id_bodega as id_bodega,
       [doc_itemDocumento].cantidadPlaneado as cantidadPlaneada,
       [doc_itemDocumento].cantidadEjecutado as cantidadEjecutada,
       [doc_itemDocumento].valorUnitarioPlaneado as valorUnitarioPlaneado,
       [doc_itemDocumento].valorUnitarioEjecutado as valorUnitarioEjecutado,
       [cat_catalogo_bodega].existencia as existencia
FROM [doc_itemDocumento]
     inner join [gen_bodega] on [gen_bodega].id = [doc_itemDocumento].id_bodega
     left join [cat_catalogo_bodega] on ([doc_itemDocumento].id_catalogo = [cat_catalogo_bodega].id_catalogo and [doc_itemDocumento].id_bodega = [cat_catalogo_bodega].id_bodega)
     WHERE [doc_itemDocumento].id_documento=@p_idDocumento and
     [doc_itemDocumento].active = 1
END


