Unfortunately, there is no concatenation aggregate function. If there was, it'd be a really simple query.
Honestly, this sounds like a client display issue. The best thing to do is select the State, County, and Zipcode columns as a full rowset and do the concatenation in the client. If you're concerned about the size of the rowset, you can use state & county artificial keys that are much smaller than the full length text of each one's name. With proper sorting, simulating a merge join in the client is quite easy and saves a lot of bandwidth. If you cache certain lookup data in the application, you can also save a lot of database hits and network traffic.
Other than handling it in the client, you're basically stuck with a loop that starts with a temp table having each State & County, and one at a time collecting the zip codes for the row into a variable and updating the row. Best practice is to avoid this at all costs.
If you have SQL 2005 you CAN do a CROSS APPLY function to get the job done, but you'll need a custom function that accepts a State & County as input and returns a comma-delimited list of zip codes for just that. This is really no different in effect and cost than the custom looping method, it's just easier to code.
I have this idea for a super-powerful and -flexible object that can transform rowsets in all sorts of ways (including pivoting) and spit out a new rowset, or array, or excel file, or csv, or whatever. That object would be perfect for this in the client.
[COLOR=black #e0e0e0]For SQL and technical ideas, visit my blog,
Squared Thoughts.
The best part about anything that has cheese is the cheese.[/color]