Solved

select distinc @list=

Posted on 2004-08-16
5
460 Views
Last Modified: 2008-01-09
-- how to get result  ',a,afsd' ?
select "id"=cast('a' as varchar(10)) into #a
insert into #a values ( 'afds')
insert into #a values ( 'a')
declare @text varchar (1000)
set @text=''
select distinct @text= @text +',' + id from #a order by id
select @text
0
Comment
Question by:ill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Author Comment

by:ill
ID: 11817999
almost forgot, without temporary table "select distinct * into #b from #a".
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11818224
I am sorry, but I don't see what you problem is, what error you have etc.
Can you precise more, because the comment mentionnes a table #b which I don't see where it comes from and what it has to do with the "question"...

CHeers
0
 
LVL 12

Author Comment

by:ill
ID: 11818272
current result of above query is
",afds"
i need it to be
",a,afds"


@#b table. i can do it with temporary table table with distinct values from table #a.
----
select "id"=cast('a' as varchar(10)) into #a
insert into #a values ( 'afds')
insert into #a values ( 'a')
select distinct * into #b from #a
declare @text varchar (1000)
set @text=''
select distinct @text= @text +',' + id from #b order by id
select @text
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 111 total points
ID: 11818332
ok, now I got it.

Instead of SELECT DISTINCT use GROUP BY

select "id"=cast('a' as varchar(10)) into #a
insert into #a values ( 'afds')
insert into #a values ( 'a')
declare @text varchar (1000)
set @text=''
select  @text= @text +',' + id from #a group by id order by id
select @text

CHeers
0
 
LVL 12

Author Comment

by:ill
ID: 11818354
shame on me :/. that's, what i was looking for.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question