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 2008 Forums
 Transact-SQL (2008)
 Multiple names into one address line

Author  Topic 

multiplex77
Starting Member

24 Posts

Posted - 2011-03-31 : 15:16:44
I have a table:

Name Address
---- -------
Jack 1 Main Street
Jill 1 Main Street
Tom 1 Main Street
Beth 1 Main Street

I want to produce a resultset that looks like this:

Name1 Name2 Name3 Address
----- ----- ----- -------
Jack Jill Tom 1 Main Street

Note: The 4th name, Beth, is ignored.

What T-SQL Statement can produce this? I've tried looping through and creating temp tables, but don't seem to be making progress. Any help would be much appreciated.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-31 : 15:18:47
Check out PIVOT in BOL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -