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)
 How Do I Combine Records in a View?

Author  Topic 

IanSouter
Starting Member

1 Post

Posted - 2003-02-19 : 19:41:00
Hi all,

I built a view in SQL Server 2000 that returns records that are exactly alike, except for one field, so multiple records are returned. I would like to combine the offending field into one.

For example:

My View Returns:
ID Name Address1 TypeOfCustomer
======================================================
22 Smith 1 Main St. Gadgets
22 Smith 1 Main St. Oodjits

But I Would Like it to Return:
ID Name Address1 TypeOfCustomer
======================================================
22 Smith 1 Main St. Gadgets/Oodjits


I've been trying multiple approaches in SQL Server 2000 (to include cross-tab queries, user-defined functions, and more), but am so far unable to complete my task.

Any ideas?

Thanks a lot,

Ian

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-02-19 : 20:36:09
What is your final goal?
What will be the front end to your data?
Have you thought about what would TypeOfCustomer look like if you had many records :

22 Smith 1 Main St. Gadgets/Oodjits/Gatgets2/Gatgets3/Gatgets4

I would suggest that if you are using a report tool like access reports or crystal reports that you return the data from your view and have the the report group your data on id and display id,name,address at the top followed by a list of TypeOf Customer

ie:


Smith
1 Main St.

Gadgets
Oodjits

Customer2
Address 2

Type1
Type2
...
Typen

However if you truly feel that your way would be best then here
is an article that might help you obtain your set

http://www.sqlteam.com/item.asp?ItemID=11021



Edited by - ValterBorges on 02/19/2003 20:38:20
Go to Top of Page
   

- Advertisement -