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

CREATE PROCEDURE [dbo].[CP_AppEve_Limpiar_Mesa_X]	 @pId_Evento SMALLINT, @pId_Mesa	VARCHAR(5)
AS


UPDATE Cbtes_Items
SET 
Cbtes_Items.Calle	= '', 
Cbtes_Items.Fila	= '', 
Cbtes_Items.Columna	= ''
FROM Productos PR
WHERE 
Cbtes_Items.Id_Producto = PR.Id_Producto
AND ISNULL (Cbtes_Items.Calle, '')    = @pId_Mesa
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)