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
 Transact-SQL (2000)
 Need Horinzontal result set

Author  Topic 

nitinag
Starting Member

20 Posts

Posted - 2004-08-07 : 20:00:06
I have a Select statement that returns me few rows(unknown number of rows) in two columns , is there a way that I can tramsform this into Horinzontal mode for example

Current Results(Remember the actual number of rows returned is unknown)

Account 5634023
CostCenter 233106021
IONumber 562

Results I would like

Account CostCenter IONumber
563.. 233.. 562..

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-08-08 : 03:57:14
Search here for crosstab or see this article http://www.sqlteam.com/item.asp?ItemID=2955 and comments for more info.

--Ken
"Knowledge is a process of piling up facts; wisdom lies in their simplification."
Go to Top of Page

nitinag
Starting Member

20 Posts

Posted - 2004-08-08 : 13:18:52
Problem is that it returns unknown number of rows(i.e. unknown number of columns for final result) . may be I am missing something but I cannot see crossTab being applied here. Here's the actual query
select field_name,
case field_type_id
when 3 then (Select dd_display from web_procure_custom_field_dropdown_details
where field_id=a.field_id and dd_value=custom_value)
else custom_value
End
as 'Value'
from web_procure_custom_field a,web_requisition_custom_field_values b
where a.field_id=b.custom_field_id and active=1
and requisition_id=@ReqId

thanks
Go to Top of Page
   

- Advertisement -