Click here to Skip to main content
15,902,112 members
Home / Discussions / Database
   

Database

 
GeneralRe: What Query i have to used Pin
khan201028-Oct-09 21:38
khan201028-Oct-09 21:38 
GeneralRe: What Query i have to used Pin
J4amieC29-Oct-09 4:15
J4amieC29-Oct-09 4:15 
GeneralRe: What Query i have to used Pin
khan201028-Oct-09 23:38
khan201028-Oct-09 23:38 
GeneralRe: What Query i have to used Pin
Rob Graham29-Oct-09 4:37
Rob Graham29-Oct-09 4:37 
AnswerRe: What Query i have to used Pin
Niladri_Biswas24-Oct-09 20:28
Niladri_Biswas24-Oct-09 20:28 
GeneralRe: What Query i have to used Pin
khan201028-Oct-09 21:42
khan201028-Oct-09 21:42 
QuestionJoining tables and get column with comma seperated values out of the join result Pin
nainakarri21-Oct-09 0:21
nainakarri21-Oct-09 0:21 
AnswerRe: Joining tables and get column with comma seperated values out of the join result [modified] Pin
J4amieC21-Oct-09 1:06
J4amieC21-Oct-09 1:06 
Although probably possible, there is no easy way to do what you want - and it runs counter to the way database queries should work.

You'd be far better off pulling your data out in the original way you posted and handling any weird aggregation of strings in code.

FWIW here's your test code


create table #myTable (a INT, b INT, c VARCHAR(10))

INSERT INTO #myTable VALUES(1,1,'x')
INSERT INTO #myTable VALUES(1,1,'y')
INSERT INTO #myTable VALUES(1,1,'z')

INSERT INTO #myTable VALUES(2,2,'j')
INSERT INTO #myTable VALUES(2,2,'k')
INSERT INTO #myTable VALUES(2,2,'l')


declare @list VARCHAR(MAX), @a INT, @b INT
SELECT @a=1,@b=1

select @list = coalesce(@list + ',' + c ,c) from #myTable where a=@a AND b=@b
select a,b,@list as c
FROM #myTable
WHERE a=@a AND b=@b
group by a,b

drop table #myTable

AnswerRe: Joining tables and get column with comma seperated values out of the join result Pin
i.j.russell21-Oct-09 1:51
i.j.russell21-Oct-09 1:51 
GeneralRe: Joining tables and get column with comma seperated values out of the join result Pin
Mycroft Holmes21-Oct-09 13:10
professionalMycroft Holmes21-Oct-09 13:10 
GeneralRe: Joining tables and get column with comma seperated values out of the join result Pin
i.j.russell21-Oct-09 21:41
i.j.russell21-Oct-09 21:41 
GeneralRe: Joining tables and get column with comma seperated values out of the join result Pin
Mycroft Holmes21-Oct-09 22:08
professionalMycroft Holmes21-Oct-09 22:08 
AnswerRe: Joining tables and get column with comma seperated values out of the join result Pin
Niladri_Biswas24-Oct-09 23:08
Niladri_Biswas24-Oct-09 23:08 
GeneralRe: Joining tables and get column with comma seperated values out of the join result Pin
nainakarri25-Oct-09 19:12
nainakarri25-Oct-09 19:12 
GeneralRe: Joining tables and get column with comma seperated values out of the join result Pin
Niladri_Biswas26-Oct-09 15:54
Niladri_Biswas26-Oct-09 15:54 
QuestionAn Extraordinarily Dumb Question Pin
Roger Wright20-Oct-09 20:15
professionalRoger Wright20-Oct-09 20:15 
AnswerRe: An Extraordinarily Dumb Question Pin
SeMartens20-Oct-09 20:41
SeMartens20-Oct-09 20:41 
GeneralRe: An Extraordinarily Dumb Question Pin
Roger Wright21-Oct-09 3:12
professionalRoger Wright21-Oct-09 3:12 
AnswerRe: An Extraordinarily Dumb Question Pin
i.j.russell21-Oct-09 3:09
i.j.russell21-Oct-09 3:09 
GeneralRe: An Extraordinarily Dumb Question Pin
Roger Wright25-Oct-09 21:40
professionalRoger Wright25-Oct-09 21:40 
GeneralRe: An Extraordinarily Dumb Question Pin
Gary R. Wheeler29-Oct-09 13:04
Gary R. Wheeler29-Oct-09 13:04 
GeneralRe: An Extraordinarily Dumb Question Pin
Roger Wright29-Oct-09 18:04
professionalRoger Wright29-Oct-09 18:04 
QuestionPrimary key on Bit Datatype in sql server 2000 Pin
Tufail Ahmad20-Oct-09 19:30
Tufail Ahmad20-Oct-09 19:30 
AnswerRe: Primary key on Bit Datatype in sql server 2000 Pin
Mycroft Holmes20-Oct-09 19:53
professionalMycroft Holmes20-Oct-09 19:53 
AnswerRe: Primary key on Bit Datatype in sql server 2000 Pin
Eddy Vluggen20-Oct-09 23:32
professionalEddy Vluggen20-Oct-09 23:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.