Visual Studio 2010, MsSql, C#, Crosstab Query

Posted on 2012-09-12
Last Modified: 2012-09-14
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?

Question by:machine_run
    LVL 35

    Accepted Solution


    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.

    LVL 18

    Assisted Solution

    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 :
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now