Monthly Archives: May 2008


Browsing through ASP.NET Forums, I found an interesting questions raised by a member that when he tried to get type information of a class using Type.GetType it was a charm in C#, but VB did not worked in same manners. He was trying to create new instances of that class at runtime, and populate those instances with data fetched from any database.

I checked its documentation in MSDN, here are its salient points, which should always be thought out before using this.

It accepts only a parameter which must contain an assembly qualified name of required type. This parameter could be only type name (i.e. "Contact") or may include namespace in it (i.e. "Hansvits.Models.Contact").

If parameter has only type name then method will search only in the assembly in which that call was made. If any full/partial assembly name is mentioned then it will load that assembly and search in it.

Continue reading

Bucketing consecutive numbers in a range

Recently we had a little tricky problem to solve. We were displaying a report in which we had to bucket numbers in a range, such that only consecutive numbers should be in that range, if any break is there, then a new range should start. Our first solution did not worked as required. Most difficult part was identifying numbers in a sequence, and placing them in a bucket. We could not create any simple T-SQL queries which could easily sort these things out. Then we thought of first capturing the bucket of each number so that we can easily work it out, and that was not possible without cursors. Lets have a look how we did that.

Continue reading

Mod operator puzzle

Recently I saw a puzzle on SQL Server Central, I was intrigued to solve it myself, so here is what I was able to accomplish, and in less than 10 minutes.

DECLARE @i int
SET @i = 0


WHILE @i < 100
    SELECT @i = @i + 1

       val % 3,
       val % 5,
            WHEN val % 3 = 0 AND val % 5 = 0 THEN 'BIZZBUZZ'
            WHEN val % 3 = 0 THEN 'BIZZ'
            WHEN val % 5 = 0 THEN 'BUZZ'
       END xval