The Bit Bucket

SQL Server 2008 R2: Free RTM eClinics

Hi Folks,

We’ve been updating the free eClinics for SQL Server 2008 R2 for the released version of the product. Three of these clinics are now published:

Master Data Services

(no longer available)

Application and Multi-server Management (Data-tier applications, SQL Server Utility)

(no longer available)

Managed Self-Service BI (PowerPivot for Excel, Reporting Services in R2, Report Builder 3.0 and PowerPivot for SharePoint)

(no longer available)

Enjoy!

2010-07-03

SQL Server 2008 R2 Reporting Services: A generic error occurred in GDI+

While building some maps today in SQL Server 2008 R2 Reporting Services, I kept coming up with an error that said:

A generic error occurred in GDI+

I was struggling to think what I’d done wrong. After much nashing of teeth and removal of hair, I finally worked out what the error was. When I got to the “Choose Color Scheme and Visualization” page of the map wizard for building a color analytical map, I hadn’t picked the correct value for the “Field to Visualize” drop-down. I’m guessing that because it had defaulted to my GEOMETRY column, instead of the field that I actually wanted to use for analysis, it must get itself into some sort of stack overflow or nesting problem.

2010-06-11

Backup a Single Table in SQL Server using SSMS

Our buddy Buck Woody made an interesting post about a common question: “How do I back up a single table in SQL Server?”

That got me thinking about what a backup of a table really is. BCP is often used to get the data but you want the schema as well.

For reasonable-sized tables, the easiest way to do this now is to create a script using SQL Server Management Studio. To do this, you:

2010-06-07

Adding included columns to indexes using SMO

A question came up on the SQL Down Under mailing list today about how to add an included column to an index using SMO. A quick search of the documentation didn’t seem to reveal any clues but a little investigation turned up what’s needed: the IndexedColumn class has an IsIncluded property.

Index i = new Index();

IndexedColumn ic = new IndexedColumn(i, “somecolumn”);

ic.IsIncluded = true;

2010-05-28

SQL Server 2008 R2: StreamInsight - User-defined aggregates

I’d briefly played around with user-defined aggregates in StreamInsight with CTP3 but when I started working with the new Count Windows, I found I had to have one working. I learned a few things along the way that I hope will help someone.

The first thing you have to do is define a class:

public class IntegerAverage: CepAggregate<int, int>

{

    public override int GenerateOutput(IEnumerable<int> eventData)

    {

        if (eventData.Count() == 0)

        {

            return 0;

        }

        else

        {

          return eventData.Sum() / eventData.Count();

        }

    }

}

In this case, I’ve defined an IntegerAverage class that inherits from CepAggregate. CepAggregate is then declared as a generic type taking an int input parameter and providing an int output. The GenerateOutput method is overriden and called when it’s time to process the input. In this case, I’ve just checked if there are any values, returned zero if not and returned an integer average if there are values.

2010-05-08

SQL Server 2008 R2: StreamInsight changes at RTM: Access to grouping keys via explicit typing

One of the problems that existed in the CTP3 edition of StreamInsight was an error that occurred if you tried to access the grouping key from within your projection expression. That was a real issue as you always need access to the key. It’s a bit like using a GROUP BY in TSQL and then not including the columns you’re grouping by in the SELECT clause. You’d see the results but not be able to know which results are which. Look at the following code:

2010-05-08