
DROP PROC Valida_TPC_ClienteProc
GO
CREATE PROC Valida_TPC_ClienteProc
( @CUSTIDSS	UD_CODCLIENT,
  @CADENA_TPC	VARCHAR(255)

)
AS
BEGIN
	DECLARE @CADENA AS VARCHAR(8000) 

	DECLARE @CADENA1 AS VARCHAR(8000)

	SET @CADENA="SELECT '" + @CUSTIDSS + "' AS CLIENTE,SITEID,INVTIDSKU  " + 
		    "FROM OP_PRCLVLCUSTDET " +
		    "WHERE PRCLVLCUSTID IN (" + @CADENA_TPC + ") " 


	SET @CADENA1="SELECT SITEID,INVTIDSKU,COUNT(INVTIDSKU)  " + 
		    "FROM OP_PRCLVLCUSTDET " +
		    "WHERE PRCLVLCUSTID IN (" + @CADENA_TPC + ")  " +
		    "GROUP BY SITEID,INVTIDSKU HAVING COUNT(INVTIDSKU)>1"
	
	EXEC (@CADENA)

	EXEC (@CADENA1)
END 
GO

Valida_TPC_ClienteProc "FF","'69YTUJ69GY','EDGAR2'"

--SELECT * FROM OP_PRCLVLCUSTDET 