February 2007 Entries

NumLock key state at logon

I use a laptop for a lot of my development, and for some reason, from time to time,  NumLock keeps turning on when I log on. I discovered this behavior is controlled by a registry key, and I'm assuming some program tweaks it on install. Here's the info: Key: InitialKeyboardIndicators All Users: HKEY_USERS\.DEFAULT\Control Panel\Keyboard Current User: HKEY_CURRENT_USER\Control Panel\Keyboard The possible settings are as follows: Off: 0 On: 2 The All Users key sets the NumLock state for the login screen.

posted @ Wednesday, February 07, 2007 6:13 PM | Feedback (11)

The comprehensive guide to Dispose, Finalization, and Resource Management

I've been developing some disposable objects, and was doing research about the proper patterns to follow. This article is a very detailed dissertation on all aspects of IDispose, Finalizers, etc in .NET. Very useful. http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=88e62cdf-5919-4ac7-bc33-20c06ae539ae

posted @ Tuesday, February 06, 2007 2:15 PM | Feedback (0)

How to create a comma seperated list from a resultset in one statement

Since I recently posted a Split UDF, I figured I'd do some research on the best way to do a Join operation. Unfortunately, UDF's can't take table variables as input parameters, so I had to just write a snippet of straight sql. Here's the solution:   DECLARE @valueList varchar(1000)   SELECT    @valueList = COALESCE(@valueList + ',', '') + CAST(Field AS varchar) FROM    Table The only way I'd seen before to do this operation involved a cursor, so it was great to come across this idea. Basically, the use of COALESCE function makes this work. For the first row, it returns an empty string, as @valueList is initially null....

posted @ Tuesday, February 06, 2007 11:57 AM | Feedback (16)

UDF - Compare two comma seperated lists

I recently had a friend ask for help comparing two comma seperated lists in SQL server using a UDF. I started based around the Split UDF I wrote, and continued from there. The simplest and most performant thing I could think of was to use an INNER JOIN to compare the table values of the two lists. Then just compare the counts you get back to make sure they're all the same. Here's the UDF: SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO CREATE FUNCTION IsCommaListMatch(   @list1 varchar(255),   @list2 varchar(255))RETURNS bitASBEGIN   DECLARE @isMatch bit    DECLARE @list1Values TABLE (val int)   DECLARE @list2Values TABLE (val int)    INSERT INTO @list1Values SELECT * FROM dbo.Split(@list1)   INSERT INTO...

posted @ Monday, February 05, 2007 2:19 PM | Feedback (0)

SQL Server Split UDF

I've seen a lot of people on the net looking for a SQL split user defined function. Looking around, there didn't seem to be anything solid and performant. I found this article from 4guysfromrolla, but looking at all those function calls makes me sick. So I wrote my own hopefully performant UDF. I removed the split character parameter, as almost all uses I saw were based on commas. But that should be very simple to add in. Let me know if you think of any other ideas to make it faster or better. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE  FUNCTION Split (    @list varchar(255) ) RETURNS @listTable...

posted @ Monday, February 05, 2007 2:13 PM | Feedback (0)

How to center an image using css

I always try to develop my sites to be standards compliant, and this means using css for all formatting and positioning when possible. I keep having to look up how to center an image, so I decided to write a post so I always know where this information is. To center an image, set the left and right margins to auto. This will make the margins fill the available space. You must also set the display to block so the image is treated as a content block. Here's a full css definition: img {       display: block;       margin-left: auto;       margin-right: auto; }

posted @ Saturday, February 03, 2007 2:08 PM | Feedback (1)