Convert rows to columns 
Author Message
 Convert rows to columns
If I have statement:

SELECT name FROM product

I get for example 100 rows as the result.

Is it possible to get one record with 100 columns?

So, instead of this:

name1
name2
name3
...

get:

name1   name2   name3 .....

Thank you for your answers,
Simon



Mon, 15 Aug 2005 22:34:40 GMT
 Convert rows to columns

www.rac4sql.net

http://www.sqlteam.com/item.asp?ItemID=2955

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q175574

http://www.sqlmag.com/Articles/Index.cfm?ArticleID=15608

http://www.fawcette.com/Archives/premier/mgznarch/vbpj/2000/14fal00/a...

--
Aaron Bertrand, SQL Server MVP
http://www.aspfaq.com/

Please reply in the newsgroups, but if you absolutely
must reply via e-mail, please take out the TRASH.


Quote:
> If I have statement:

> SELECT name FROM product

> I get for example 100 rows as the result.

> Is it possible to get one record with 100 columns?

> So, instead of this:

> name1
> name2
> name3
> ...

> get:

> name1 name2 name3 .....

> Thank you for your answers,
> Simon



Mon, 15 Aug 2005 22:59:33 GMT
 Convert rows to columns
Try this. It will return only one field instead of 100 fields:





Quote:
> If I have statement:

> SELECT name FROM product

> I get for example 100 rows as the result.

> Is it possible to get one record with 100 columns?

> So, instead of this:

> name1
> name2
> name3
> ...

> get:

> name1 name2 name3 .....

> Thank you for your answers,
> Simon



Mon, 15 Aug 2005 23:05:44 GMT
 Convert rows to columns
That method is neither documented nor reliable. Sequential concatenation of
row values are very risky, unpredictable and may fail for changes in
underlying datasets, indexes etc and hence should never be considered as a
safe solutions in stable environments.

--
- Anith
(Please respond only to newsgroups)



Tue, 16 Aug 2005 00:11:17 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. convert row to column

2. converting rows to columns

3. converting rows to column

4. converting rows to columns

5. Converting ROW to Columns

6. how to dynamic create a table (converting rows to columns)

7. How to Convert rows into Columns

8. convert row to column

9. How to convert rows to columns

10. Converting rows to columns

11. Converting 1:M rows into a single row with multiple columns

12. convert a columns values in to five columns a row


 
Powered by phpBB® Forum Software