ALTER FUNCTION [dbo].[proNotasPedidoPorOP] ( @ordenproduccion Int ) 
RETURNS varchar(100)
AS
BEGIN
    DECLARE @op int = @ordenproduccion
    DECLARE @notaspedido varchar(100) = ''
    
    SELECT @notaspedido = STUFF(
        (SELECT ', ' + CAST(np AS varchar) 
         FROM proOPDetalleNP XT
         WHERE XT.idOP = @op
         FOR XML PATH('')), 
        1, 2, '')
    
    RETURN @notaspedido
END