/***************************************
* function f_genNewCodUDC
*
* fornisce un nuovo cod UDC a partire da 
* - codice origine completo
* - Flusso (nuovo)
* 
* es: USPRX14000005 + "TT" --> USPTT14000005
*
* Steamware, S.E.L.
* mod: 2014.03.14
*
****************************************/
CREATE FUNCTION [dbo].[f_genNewCodUDC]
(
	@SourceUDC	NVARCHAR(50),
	@Flusso		CHAR(2)
)
RETURNS NVARCHAR(50)
AS
	BEGIN
	
		DECLARE @answ AS NVARCHAR(50)
	
		SET @answ = SUBSTRING(@SourceUDC, 1, 3) + @Flusso + SUBSTRING(@SourceUDC, 6, LEN(@SourceUDC) - 5)
	
	RETURN @answ
END