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

SQL View Question

Status
Not open for further replies.

rob11nj

Programmer
Jan 5, 2006
18
US
I'm using MSSQL 2005 and am trying to create a view that does the following.

If the dataset looks like this:

Column A Column B
---------------------
host1 ABC
host2 AAA
host1 CDE
host3 FFF
host2 BDE
host1 ZZZ

The output of the view would be something like this:

Column A Column B
---------------------
host1 ABC,CDE,ZZZ
host2 AAA,BDE
host3 FFF

So basically column A will be distinct records and column B will be a string that contains all of the column A records separated by a comma. Does anyone know of a simple way to accomplish this in a view?

Thanks!
 
Does this have to be a view, or can you use a stored procedure with a User defined function?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks gmmastros for the link and quick response.

I'm really looking for a way to do this in a view though. Any suggestions would be very much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top