Friday, January 05, 2007

This past week I've been completely engrossed in debugging software and assisting to resolve customer issues.  It's been a very good and productive week, but not too technical (hence the dearth of programming-targeted posts), at least not technical enough to warrant a post.

This weekend, however, I will be in Las Vegas, NV for, among other things, the 2007 International CES Conference.  The conference starts on the 8th and runs through the 11th, though I'll only be there on Monday and Tuesday, flying home that evening.

Prior to that I'll be working with two of my compatriots at Experlogix in an offsite meeting that I'm very excited about.  I hope to accomplish a lot this weekend.

All things are looking up.

Friday, January 05, 2007 10:15:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, January 01, 2007

It's pretty exciting to get the year started off this way.  I received notification today via email that I was accepted for the second year as a Microsoft MVP.  :)  I hope that more can be accomplished this coming year and the .NET community strenghtened.  Thanks to all those that contribute and make our community rock!

Monday, January 01, 2007 7:04:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Thursday, December 28, 2006

I've been very quiet on the blogging front this month, especially over the past couple of weeks.  I took some time off to finish off some long overdue projects around the house (namely the basement).  With the exception of Christmas Day, I've been downstairs almost every waking hour trying to wrap it all up.  Tonight I got all of the caulking and spackling done on all of the baseboards and trim.  Essentially, all that remains is painting (baseboards, trim, and walls), but that's a pretty big undertaking that will occupy every hour of my weekend.  We're installing the carpet on Monday so I have my work cut out for me.  I'll post some pictures when it's all done.

On the positive side, I'll be able to get my office downstairs (finally!) in about a week (after I get all of the outlets and switches wired up) and free up a much needed bedroom upstairs.

Just wanted to drop in and let everyone know I've not gone away, that I'll be back and blogging some pretty good stuff in the coming days (following the vacation), and to wish everyone a Happy Belated Christmas and a Happy New Year :)

Thursday, December 28, 2006 3:59:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, December 21, 2006

Being the major Potter-phile that I am, I can't resist but to put this out there: the next/last book's name has been officially announced.  Harry Potter and the _____ _____.  The name is actually embedded in a hidden easter egg on J. K. Rowling's website.  I must admit that I was sorely disappointed upon hearing the news of the new title and opening the article that the putz author included the name right in the first line of the article only to explain a few paragraphs down that, "oh, by the way, you can find out about the name on J. K. Rowling's site via a fun hangman game."

So as to not spoil the news (unless you already know), and to make it more entertaining, here are the instructions to the easter egg, as provided by the MSN article in question (spelling errors and all :), with a little more organization and clarity):

  1. Open her home page.
  2. Click on the eraser and you will be taken to a room - you'll see a window, a door, and a mirror.
  3. In the mirror, you'll see a hallway.  Click on the farthest doorknob and look for the Christmas tree.
  4. They [sic] click on the center of the door (ed: the center of the top panel) next to the mirrow and a reef [sic!] appears.
  5. Then click on teh top of the mirror and you'll see a garland.
  6. Look for a cobweb next to the door.  Click on it, and it will disappear.
  7. Now, look at the chimes in the window.  Click on the second chime to the right.
  8. Click it again, holding down the mouse button (rephrased).  The chime will turn into a key, which opens the door (drag it onto the lock on the door).
  9. Click on the wrapped gift behind the door.
  10. Then click on it again and figure out the title yourself by playing a game of hangman.

Gee, figure it out after I already told you the answer! grrrr.

Thursday, December 21, 2006 8:28:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, December 15, 2006

Within the context of SQL Server, retrieving the server version is pretty easy, and there is a variety of ways one can go about retrieving the information.

You might consider calling the sp_server_info sproc that I mentioned in a post yesterday with specifying the attribute id of '2':

EXEC sp_server_info 2

Unfortunately, this returns columnar data so unless you do something like I proposed in said post it's largely unhelpful.  Alternatively, and much more simply, you can query the @@version function (which I suspect ultimately defers to the same data that the sp_server_info sproc returns):

SELECT @@version

Still, this data may not be what you're looking for.  It's quite verbose and contains a lot of extraneous information.  You may be after just the version number.  Fortunately, this is quite easily accomplished by querying the serverproperty function.

SELECT serverproperty('ProductVersion')

Incidentally, there is a lot more information you can glean from the server via the serverproperty function (product level, edition, instance name, and much more).

You may have need to write some TSQL that is conditional based on the target SQL Server edition.  For instance, I'm in the process of writing software that must run on both SQL Server 2000 and SQL Server 2005, but where possible I'd like to use SQL Server 2005's capabilities and not necessarily cater to the least common denominator of SQL Server 2000.

The ProductVersion may still be too specific, as it contains minor versions, SP updates, etc.  Essentially, what I want is to ensure that I'm dealing with the correct DB engine by major version # and not take into consideration any minor updates.  The following code illustrates in a very simple manner extracting just the major version from the property.  In this case, the TSQL simply returns a string indicating what was detected, but your code may actually contain logic:

DECLARE @ver nvarchar(128)
SET @ver = CAST(serverproperty('ProductVersion') AS nvarchar)
SET @ver = SUBSTRING(@ver, 1, CHARINDEX('.', @ver) - 1)
IF ( @ver = '8' )
   SELECT 'SQL Server 2000'
ELSE IF ( @ver = '9' )
   SELECT 'SQL Server 2005'
ELSE
   SELECT
'Unsupported SQL Server Version'

Friday, December 15, 2006 3:18:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [2]  |  Trackback

It looks as though Microsoft did in fact release the Visual Studio 2005 Service Pack 1 yesterday.  It's a hefty download (approx 432 MB), but I hope it's worth it.  I imagine it would take a lot to fix many of the 'house-of-cards' issues that VS 2005 has.

Be forewarned, however.  I can't recommend running it on Vista yet.  Within the download instructions it clearly states that 1) the installation on Vista will take a long time (up to an hour just to verify digital signatures) and 2) there's an additional update to SP1 for Vista that is currently in Beta.

Enjoy :)

Friday, December 15, 2006 2:52:00 AM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, December 14, 2006

I've always found working with stored procedures that return tabular data somewhat cumbersome within the context of another stored procedure.  In other words, it's not the most intuitive of tasks to call a stored procedure that returns a rowset and work with its data from within a stored procedure.

There are several approaches that one might take to accomplish this.  Creating a temporary table or a CURSOR come to mind immediately as two valid approaches.  In fact, in SQL Server 2000, I found a temp table to be the most reliable way to work with data in this manner.

As a for instance, there is a stored procedure in SQL Server called sp_server_info.  This procedure, when executed without parameters, will return a three-column resultset consisting of an ID, an attribute name, and an attribute value identifying various attributes of the SQL Server itself.  You can also call the stored procedure specifying the ID and it will return the row identified by the ID.

Furthermore, SQL Server 2000 introduced the concept of TABLE-type variables.  However, they were largely useless in this context because you couldn't INSERT INTO a table variable the resultset from a stored procedure.

This changes in SQL Server 2005, however.  Let me illustrate this with a very simple, contrived example.

Suppose that I wanted to call the sp_server_info from a stored procedure, work with the data, and return it to the caller.

CREATE PROCEDURE dbo.GetSprocVersion AS
  -- Create a table variable that matches the resultset of the stored procedure
  DECLARE @tmp TABLE (
    attribute_id int, attribute_name varchar(60), attribute_value varchar(255)
  )
  -- Populate the table variable by invoking the stored procedure
  INSERT INTO @tmp EXEC sp_server_info
  -- Return the appropriate result
  SELECT attribute_value FROM @tmp WHERE attribute_id = 500
GO

What I like about this example, if you look closely, is that you can call INSERT INTO..EXEC on a TABLE variable :) - very cool!  Now, I can make this code slightly more exciting by doing the following:

CREATE PROCEDURE dbo.GetSprocVersion AS
  -- Create a table variable that matches the resultset of the stored procedure
  DECLARE @tmp TABLE (
    attribute_id int, attribute_name varchar(60), attribute_value varchar(255)
  )
  -- Populate the table variable by invoking the stored procedure
  INSERT INTO @tmp EXEC sp_server_info 500
  -- Return the appropriate result
  SELECT attribute_value FROM @tmp
GO

In this particular example I invoke the stored procedure passing a parameter.

Ok, this isn't rocket science, but as you can see, it makes it very easy to work with set data using a TABLE variable.  I envision this may be more useful were you to call a sproc that returned a larger set (say a set of customers) and then process that result to return either a finer resultset, massage the data, or otherwise.

Thursday, December 14, 2006 4:44:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [6]  |  Trackback
 Wednesday, December 13, 2006

...
"The time has come," the coder said,
"To talk of many things:
Of loops - and blocks - and heaps and stacks -
Of variables - and strings -
And why you see AND, OR, 'n NOT
And whether the NIC blocks pings.
...

          - Adapted from Lewis Carroll's Jabberwocky

Tomorrow (December 14th, 2006) we'll have the December installment of the Utah .NET User Group.  We're very excited to have Robert Green (more recent/updated website/blog?) visiting us from out of town.  He'll be talking about "Developing Office 2007 Solutions with Visual Studio Tools for Office 2nd Edition" (VSTO SE).

Come one and all - it should be a great event!

Time: 6:00 PM
Date:
December 14th, 2006
Place: Neumont University (10701 South River Front Parkway, South Jordan, Utah)

See you there!

Wednesday, December 13, 2006 4:20:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, December 08, 2006

This past week was very exciting.  Not only did I have the opportunity to work with a potential customer on a pilot, proof-of-concept integration to our existing product configurator, but I met some great friends in the process.

As I mentioned in my post a few days ago, I was down in Longmont, Colorado (a delightful place on many levels) working with a prospective customer and demonstrating some very cool software.  I also had the distinct honor to meet some great developers: Hailu, Praveen, Jvalin, and Atul (all of various Indian heritages).  I hope they had as good a time working with me as I did with them.

Perhaps the highlight of my entire time there was spent with my best friend of over 20 years, Erik Peticolas, and his wife Nancy who live in Denver.  I haven't had the chance to see them since my days at Microsoft when I would travel to Denver on a monthly basis for our monthly District Meeting and would purposfully make it a point to see them and have dinner at the very least.  We had the chance to go our four times this past week which was quite a treat.

Now I'm home and very tired, but very satisfied at a great week.

Friday, December 08, 2006 3:18:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback