Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accumulating in a local variable
Message
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Accumulating in a local variable
Miscellaneous
Thread ID:
00662107
Message ID:
00662107
Views:
41
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.
Next
Reply
Map
View

Click here to load this message in the networking platform