Learn more about SQL Server tools



solving sql server problems for millions of dbas and developers since 2006 join MSSQLTips for free SQL Server tips
































Top SQL Server Tools



































   Got a SQL tip?
            We want to know!

Cross tab queries with SQL Server 2000

MSSQLTips author Greg Robidoux By:   |   Read Comments   |   Related Tips: 1 | 2 | More > Scripts
Problem

In SQL Server 2000 there is no simple way to create a cross tab query.  Generally crosstab queries are only used for reporting or if you want to display some information in a grid on an application screen.  Other then displaying or reporting on data there isn't a real need for this type of query.  But when the need arises for either one of these reasons, there is no simple way of doing this in SQL Server 2000.  This may come as a big surprise to people that have been doing this in Microsoft Access for quite some time. With Microsoft Access there is a built in option to produce crosstab queries, but not so with SQL Server 2000.

Solution

As mentioned above there is no simple way to produce a cross tab query, but several implementations have been produced and are available on the internet.  Finding all of these options, understanding them, implementing and testing takes some time, so to make your life a little easier we have gathered a list of some useful variations on how to produce cross tab queries in SQL Server 2000.

The following solution is pretty straight forward and offers a lot of flexibility.  Although it met my needs, take a look at the other options as well to see which one makes the most sense for your needs.

This is a list of various implementations and methods for creating crosstab queries for SQL Server 2000. There are probably others out there as well.

Some other options that do not require T-SQL coding include the following:

Next Steps
  • Take a look at these various methods for creating crosstab queries
  • Select a method that works best for your environment
  • Modify these methods to implement the right solution for your needs


Last Update: 6/15/2006


About the author
MSSQLTips author Greg Robidoux
Greg Robidoux is the President of Edgewood Solutions and a co-founder of MSSQLTips.com.

View all my tips


print tip Print  
Become a paid author





join MSSQLTips for free SQL Server tips     



Learn more about SQL Server tools
Comments and Feedback:

Post a Comment or Question

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email Notify for updates



Comments
Get free SQL tips:

*Enter Code refresh code


 
Sponsor Information







Copyright (c) 2006-2014 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | free t-shirt | user groups | community | events | first timer?
Some names and products listed are the registered trademarks of their respective owners.