• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1263
  • Last Modified:

Visual Studio 2010, MsSql, C#, Crosstab Query

Trying to find out how to create crosstab queries for charts in Visual Studio 2010, C# Winform application, from a MS SQL database. Looks like the VC 2005 crosstab wizard is moved or gone. I don't want to use Crystal Reports if possible.

Anyone know how to create one in Visual Studio 2010?

TIA
0
machine_run
Asked:
machine_run
2 Solutions
 
David ToddSenior DBACommented:
Hi,

Crosstab queries are now fairly easy in SQL. You could always do these with a bunch of case statements in the select, or since SQL 2005 there is the pivot operator.

Can I suggest that unless you are doing something really unusual, fair better to do this in the sql query, rather than on the front end.

Also SQL 20012 now has better windowing and paging in the results set, so less work to do when displaying multiple pages.

Okay, so what do I need to give a better answer:
SQL version
SQL schema - tables and so forth and some sample data to test.

HTH
  David
0
 
vastoCommented:
If it is MSSQLServer2005 (as the topic shows) then you can use PIVOT operator to prepare the data on the server side. In your project this will be processed as a regular command.

You can check this example how to create a dynamic pivot table in SQLServer 2005 :
http://www.simple-talk.com/blogs/2007/09/14/pivots-with-dynamic-columns-in-sql-server-2005/
0
 
machine_runAuthor Commented:
THANKS!
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now