Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accumulating in a local variable
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Accumulating in a local variable
Divers
Thread ID:
00662107
Message ID:
00662107
Vues:
40
I need to accumulate in a local variable a valstring value.
But, for some reason, this not working, the code is:
USE Osiris
GO

DECLARE @txt VARCHAR(1000)
DECLARE @txtaux VARCHAR(120)

SET @txt = ''
SET @txtaux = ''

DECLARE cur_text CURSOR FOR 
   SELECT texto FROM Universe.dbo.textOdi 
             WHERE Universe.dbo.textOdi.certif = 'PM115451'
	OPEN cur_text
	FETCH NEXT FROM cur_text INTO @txtaux
	WHILE @@FETCH_STATUS = 0
	BEGIN
		FETCH NEXT FROM cur_text INTO @txtaux
		SET @txt = @txt + @txtaux
	END
	CLOSE cur_text
	DEALLOCATE cur_text

PRINT @txt
Why the @txt local variable doesn't have any accumulated value, if this value this being assigned with the SET commando ?

Thanks.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform