Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Horizontal display

Status
Not open for further replies.
Jun 11, 2008
34
US
SQL by default displays instances of data vertically. I have a situation where I have a gifthrnkey and giftid. If there are multiple gifthrnkeys and giftid, I want to list the output horizontally. For example in a normal sql query of select gifthnrkey,giftid from gift_table, the output would be:
gifthrnkey Giftid
0012 1111
0012 1113

I want it like this

gifhnrkey giftid1 giftid2
0012 1111 1113

How can I do this in a select statement in query analyzer??
 
Check the FAQ's for this forum. I believe there are some written up for this. Alternatively, search some of the older threads here. This is a common SQL Server question, so there are lots of answers for this question in the archives.
 
It was buried a ways down the list.
This does something close enough to what you want.

faq183-2146


-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top