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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First Question Here,Look Forward to Any Help 2

Status
Not open for further replies.

SandroHappyUFO

Programmer
Mar 30, 2005
36
0
0
CN
hi,all
i have 2 tables as blow:
1/master_table : col1
Tom
Jack
2/detail_table : col1 col2
Tom Magic
Tom KongFu
Jack Sword
now i want to get the result as below in 1 SQL:
col1 Tom Magic,KongFu
col2 Jack Sword

may i ? ONE SQL?
 
Welcome to the site.

Doing this will require a function to return the data. There are several examples in this and the admin forum on how to do this.

The function will need to use a curser to get all the values based on the name that you pass the function. You will then call the function.

By using a function your performance will take a major hit as functions are not effecient at all.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
There is an example here on how to create that function (it's near the bottom). thread183-1159740

Post back if you have any questions.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks gmmastros. I didn't have that in my archive. I seam to always forget to add them when these questions come up.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top