Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query question on returning unique records

Author  Topic 

tribune
Posting Yak Master

105 Posts

Posted - 2001-12-27 : 12:53:12
I need to return the following recordset, with a unique key row (ComputerID) and the IPaddress concatenated into a csv. For example:

ComputerID ComputerName IPAddress
----------- -------------------- ---------------
1 wwwserver NULL
....
9 WEBMASTUH 10.0.0.44
9 WEBMASTUH 204.214.40.66

Need this:

1 wwwserver NULL
....
9 WEBMASTUH 10.0.0.44, 204.214.40.66

Any ideas?

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2001-12-27 : 13:38:45
I'd search on CSV (http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv). You'll find a couple of articles on converting a series or rows into a CSV.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

tribune
Posting Yak Master

105 Posts

Posted - 2001-12-27 : 14:17:51
argh that stored procedure for csvs looks like a lotta code for what seems to be such a simple task! :(

i doubt think it would be more efficient than the asp workaround i did

right now i just have a 'do...loop until' that checks to see if the key for the recordset has changed or not to write out the column

if anyone has a quick-er fix or another idea i'd appreciate it :)

Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-27 : 14:28:08
Which stored procedure are you talking about? If you look over the entire list of articles that graz's search returns, you'll find this one [url]http://www.sqlteam.com/item.asp?ItemID=2368[/url] that explains how to use COALESCE to do what you're asking. You'll probably need to combine it with a GROUP BY or subquery to get your final result.

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page

tribune
Posting Yak Master

105 Posts

Posted - 2001-12-28 : 01:07:26
Ah my bad, I missed that fine article at work. Great work, thanks :)

Go to Top of Page
   

- Advertisement -