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 2005 Forums
 Transact-SQL (2005)
 Selecting Multiple Rows with the same

Author  Topic 

wshawnsmith
Starting Member

2 Posts

Posted - 2009-04-14 : 16:03:03
below is the results from the query

select ProductNo
,UPC+'<mulitsep/>'+
isnull(I2o51+'<mulitsep/>','')+
isnull(I2o52+'<mulitsep/>','')+
isnull(I2o53+'<mulitsep/>','')+
isnull(I2o54+'<mulitsep/>','')+
isnull(I2o55+'<mulitsep/>','')+
isnull(I2o56+'<mulitsep/>','')+
isnull(I2o57+'<mulitsep/>','')+
isnull(I2o58+'<mulitsep/>','')+
isnull(I2o59+'<mulitsep/>','')
from UPCBuildTEMP2
where GlobalProductNumber is not null
and ProductNo=100016


100016 0-81999-12334-5 1 PIECE<mulitsep/>1-00-81999-12334-2 (128) PIECES<mulitsep/>
100016 0-73291-32620-3 1 PIECE

I need to select 0-73291-32620-3 1 PIECE
in the same row instead of a different one, to look like this:

100016 0-81999-12334-5 1 PIECE<mulitsep/>1-00-81999-12334-2 (128) PIECES<mulitsep/>0-73291-32620-3 1 PIECE

But it is a different row. And I do not want to do a cursor, is there a simple way to select the next UPC and any I205s it may have out?

Kokkula
Starting Member

41 Posts

Posted - 2009-04-15 : 02:45:43
Hello,

It can be done using the pivot and unpivot concepts.

Refer link:
http://msdn.microsoft.com/en-us/library/ms177410.aspx

Hope helpful...


Thanks,
Pavan
Go to Top of Page

wshawnsmith
Starting Member

2 Posts

Posted - 2009-04-16 : 14:14:57
These are varchar fields, PIVOT won't work. Right? At least I can't get it to.


Shawn
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-16 : 14:27:02
see this

http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
Go to Top of Page
   

- Advertisement -