Showing posts with label TSQL. Show all posts
Showing posts with label TSQL. Show all posts

Wednesday, April 06, 2011

Setting-up Windows Development Environment virtually on Linux

My laptop runs Ubuntu Linux 10.04 Desktop, but given I hope to start tackling some C# projects at home on Microsoft Visual Studio 2010 I needed to setup an environment to code under. I'm a huge fan of virtualization and given I already run a few Operating Systems on my system via VirtualBox I decided to just install Windows, SQL Server, and VS 2010 that way.

Though I haven't taken classes in a year or so my account on Microsoft Dreamspark is still active so I downloaded Microsoft Windows Server 2008 R2 Standard, SQL Server 2008 R2 Developer, and Visual Studio 2010 Professional. After this I setup my Virtual environment in VirtualBox and got busy installing.

Windows Server only took about 15 minutes to install, but it took probably 2+ hours to install all the updates. Then after installing SQL Server then Visual Studio likewise the updates took forever. I also found this MSDN Blog posting showing how to use Windows Server as a 'Super Desktop' so I went through some of these tips to setup Windows Server 2008 R2 more like a Windows Desktop so I wasn't bothered by all the security crap.

After all this plus installing a slightly older version of Microsoft Office (I think 2005) I was ready to go! I grabbed the ASP.Net AJAX Toolkit which added some NICE tools to VS plus I'm reviewing two different sites to find some open source C# tools:

I need to find some open source tools for reporting and also for saving content to PDF.

So all and all my environment is now setup and ready to go, so now I just need to find time to actually start coding :)

Friday, April 01, 2011

Pivoting a large table, like Cash Flows, in TSQL

I often have to pivot large amounts of data, but the Pivot option in TSQL can be VERY limited especially when there is a large amount of data. The TSQL query below will create a sample Cash Flow table then pivot it on Date, but this can be modified to pivot the data in any number of ways.



The output will look similar to this:

AccountID [2010-1] [2010-2] [2010-3] [2010-4] [2010-5] [2010-6]
123 117.89 515.86 205.81 516.29 387.64 30.84
390 363.94 992.20 197.64 516.29 248.20 172.05
687 129.86 562.17 839.67 790.28 790.28 898.51

I've used a query similar to this for pivoting LARGE cash flow tables for reporting, and given you have no objections to using Dynamic SQL this is a great way to pivot large amounts of data.

Have fun and please post comments and suggestions.