IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'dbo.CP_AppEve_Cambiar_Mesa') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE dbo.CP_AppEve_Cambiar_Mesa
END
GO

CREATE PROCEDURE [dbo].[CP_AppEve_Cambiar_Mesa]	 @pId_Evento SMALLINT, @pId_Mesa1	VARCHAR(5), @pId_Mesa2	VARCHAR(5)
AS


UPDATE Cbtes_Items
SET 
Cbtes_Items.Calle	= @pId_Mesa2, 
Cbtes_Items.Fila	= '0', 
Cbtes_Items.Columna	= '0'
FROM Productos PR
WHERE 
Cbtes_Items.Id_Producto = PR.Id_Producto
AND ISNULL (Cbtes_Items.Calle, '')    = @pId_Mesa1
AND Cbtes_Items.Id_Trans IN (SELECT DISTINCT(CI2.Id_Trans)
							FROM 
							Cbtes_Items CI2 ,Productos P2, Prod_Listas_Precios_Items LPI
							WHERE 
							CI2.Id_Producto = P2.Id_Producto
							AND LPI.Id_Producto = CI2.Id_Producto
							AND P2.Id_Familia NOT IN (dbo.CF_xParam('Flias_Habitaciones'), dbo.CF_xParam('Flias_Mesas'))
							AND P2.Vendible = 1 							
							AND LPI.Id_Lista_Precio = @pId_Evento)



