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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rows to Columns

Status
Not open for further replies.
Jun 12, 2009
123
GB
Hi All,

Iam using SQL Server 2008 r2 and wanted to know when I get my results can I change the view method from horizontal to vertical as you can do in Oracle.

Many Thanks
 
Also please can someone advise, in SQL server 2008 r2, is there functionality that allows you view the related tables/fields to appear in a quicker way in Management Studio when typing queries e.g. autotext?

Many Thanks
 
Informer30,
to the first question, not that I am aware of.

to the second, what do you mean? The latest version of SQL has intellisense, which will provide table/column names.

Lodlaiden

A lack of experience doesn't prevent you from doing a good job.
 
For the first question, there is PIVOT operator added recently to T-SQL

There is also built-in intellisense in SQL Server 2008 SSMS. Alternatively, you may want to consider SQLPrompt from RedGates. I had it installed for a trial period recently and I really liked it.

PluralSight Learning Library
 
Thanks guyz,

but how do I get these started I am looking around and no joy....

Many Thanks
 

Presuming you are using the correct version of SQL Server management Stuido then under "Query" you will see an option to enable Intellisense.

For use of Pivot, It's a function of SQL not a display option the way it is in Oracle.

I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
Thanks....Intellisense is enabled how does it work....I dont get it...?I am still typing/dragging table/field names etc....
 
When you type

select t. -- do you see columns here?
from myTable as t

If not, and you have installed SQL Server 2008 R2 and VS 2010 SP1,
then you will need to install the latest Cumulative Update for SQL Server (CU7), as this is a bug, which was fixed in the mentioned CU7.

For PIVOT, I suggest to read this blog post
Understanding PIVOT 2000

It does not use PIVOT syntax, but it's important to understand this technique, as unlike PIVOT it can be used for multiple columns.

And if you want a dynamic pivot on multiple columns, then you may review another blog post
Dynamic Pivot on multiple columns


PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top