Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TSQL problem

Status
Not open for further replies.

habneh

Programmer
Mar 21, 2007
55
US
declare @name varchar(1000)
set @name = ''

1 select @name = @name + convert(varchar(1000),id)+ ', '
from tbl

2 select @name

How can I combile statement 1 and 2 so that I can do it in a single statement

select (select @name = @name + convert(varchar(1000),id)+ ', '
from tbl)

gives me an error

Thanks
 
The example page is not the EXACT same problem as what you have, but it does state that you can not retrieve any data from a select that also assigns a value to a varaible, so even putting the assigning select into a subquery won't fix the problem.

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top