Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accumulating in a local variable
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00662107
Message ID:
00662136
Vues:
25
Thank you Michael and Sergey:

The problem was that exist an NULL value in field 'texto' and the solution was include an IF asking for a NULL value.
Apparently command '+' doesn't concatenate when it finds a value NULL and it loses (?) the current content.
	WHILE @@FETCH_STATUS = 0
	BEGIN
		FETCH NEXT FROM cur_text INTO @txtaux
		IF @txtaux IS NOT NULL
			SET @txt = @txt + @txtaux
	END

	PRINT 'Complete string: ' + @txt
>Sergey pointed out one problem - you've got the FETCH in the wrong place within the loop. What value are you seeing for @txt vs. what value do you think you should be seeing? Also, give this a try:
>
>
>DECLARE @txt nvarchar(4000)
>
>SELECT
> @txt = @txt + texto
>FROM
> Universe.dbo.textOdi
>WHERE
> certif = 'PM115451'
>
>SELECT @txt
>
>
>It should produce the same results.
>
>-Mike
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform