Código SQL:
Ver originalCREATE TABLE #table
(
id INT,
codigo VARCHAR(20)
)
INSERT INTO #table VALUES (1,'AAAAAAAA')
INSERT INTO #table VALUES (1,'BBBBBBBB')
DECLARE @variable VARCHAR(100)
SET @variable=''
SELECT @variable=@variable + ' ' + codigo FROM #table
print @variable
Prueba con algo asi :)
Saludos!