SQL Server 2005: New data types

I recently had a job interview and one of the questions in the written exam that they gave me was about the new data types in SQL Server 2005.  I did get most of them.  So here are the new data types in SQL Server 2005, in case you wanted to know:


As the name suggests, this data type can store XML data.

VarChar(MAX), NVarChar(MAX), and VarBinary(MAX)

These are called large value data types.  By specifying the MAX keyword in the VarChar, NVarChar, and VarBinary data types, you essentially increased the storage size of these data types to 2^31 – 1 bytes.


General: Programming Test #1

There was this test in one of the job interviews I had recently that I did not ace well.  It was a written programming test.  I have not been given a written programming test for a while so I was caught off-guard.  If this was a hands-on, I would have aced it.  Anyways, here is some more details about the problem.

Given an input of 1-7 indicating the day of the week (Sunday being a 1, Monday a 2, and so on…) for the first day of the month, print a calendar for that month.  I fired my Visual Studio 2005 and started coding in VB.  After 3 iterations of the code (I like to make my code small and easy to understand which is why I usually do more than 1 iterations of the code), I came up with this solution:

    Public Sub PrintMonthCalendar(ByVal DayOfWeekFirstDayOfMonth As Integer, _
                                    ByVal NumberOfDaysInMonth As Integer)
        Dim i As Integer
        Dim intDay As Integer = 1

        Console.WriteLine("Su Mo Tu We Th Fr Sa ")
        For i = 1 To NumberOfDaysInMonth + (DayOfWeekFirstDayOfMonth - 1)
            If i < DayOfWeekFirstDayOfMonth Then
                Console.Write("   ")
                If i Mod 7 = 0 Then
                    Console.WriteLine("{0,2} ", intDay)
                    Console.Write("{0,2} ", intDay)
                End If
                intDay += 1
            End If

    End Sub

Here are some sample outputs of the program:

VB 2005: Don’t use the Timer control on your Windows Service project

Just wasted my time trying to debug why the Timer control (from the Toolbox under Components) on my Windows Service project was not working at all.  Then I tried explicitly creating a Timer object from the System.Timers.Timer class and now it is working.

One thing I noticed though is that when I used the Timer control, the event that is fired when the interval has elapsed is the Tick event while when I used the Timer object from the System.Timers.Timer class, the event fired is the Elapsed event.  Found out that they are different because the Timer control is created from the System.Windows.Forms.Timer class.