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)
 Horizontal To Vertical Record

Author  Topic 

sanj
Starting Member

22 Posts

Posted - 2012-11-08 : 12:36:28
Hi,

I am trying to convert a horizontal recordset to vertical, I've seen some other post an know I need a pivot table but have got confused:

the recordset output looks like:

my query is:

SELECT tbl_reviews.ReviewerID, tbl_reviews.ReviewerStatus, tbl_reviews.ReviewerComments, tbl_Files.Type, tbl_Files.FileName, tbl_Login_1.CompanyName, tbl_Login_1.ContactName, tbl_Files.FileID

FROM tbl_Login AS tbl_Login_1 RIGHT OUTER JOIN
tbl_reviews ON tbl_Login_1.LoginID = tbl_reviews.ReviewerID LEFT OUTER JOIN
tbl_Login INNER JOIN
tbl_Files ON tbl_Login.LoginID = tbl_Files.LoginID ON tbl_reviews.FileID = tbl_Files.FileID
WHERE (tbl_Files.FileID = 37)


The Current Output is

13 A NULL Docs Doc1.pdf ABC username1 37
9 NULL NULL Docs Doc1.pdf DEF username2 37


I am looking at returning the recordset as:

37 Docs Doc1.pdf 13 A Null ABC username1 9 Null Null DEF username2


Any help is appreciated.
   

- Advertisement -