Sometimes I just like to geek with computers and programming. I like to geek with code, only for the sake of just geeking. You know, quality geek time. Contrary to what some believe, some DBAs can program in a procedural language or procedurally in TSQL. For instance, I have no problem firing up a c++ compiler and building Extended Stored Procedures (now deprecated by the way, even though all of the xprocs in SQL 2005 are still c or c++ ) and building a nice plan-jane .dll to stick in the SQL namespace. Or,  I'll be found up late at night working on my Win2003 domain. And, gasp, as of late I've been playing around with my Linux box, doing some fun stuff with other database platforms, such as Postgres, MySQL, and FirebirdSQL (the product from Firefox). All neat stuff.
Awhile back, I was digging through some code and found some of the old Match.com search procs. You know, the site that matches up all of these guys claiming to be pilots and doctors to beautiful heiresses worth millions. The old search engines used a technique called Bitmasking to stored the main attributes of a top-level search (age, hair color, height, city, state). This served as a very nice way to eliminate a goodly-sized chunk of search candidates, which provided a more manageable result set to consume.
You've probably seen bitmasking techniques in procedural code SQL Server 7 and 2000, or you have maybe used them yourself. Oftentimes it serves as a handy way to handle permission assignment for users, as a "classic" example. There is one technique that you might not have seen - collapsing many attributes into a mask. This month I wrote an article for SQLServercentral.com, part 1 in a series of what I think is a neat bitmasking technique. You may or may not have seen this before - I certainly have not in an article for sure. This article, by the way, is scheduled to go out on December 11, 2006 via email to nearly 200,000 subscribers to the daily emailer. SQL Server Central is a community of developers and dbas sharing tips and tricks in the SQL Server world.

Part one of Introduction to Bitmasking in SQL Server 2005 goes over the basics of numbers and counting, necessary for masking operations,  and a simple example of when you might actually use this technique. It's really not altogether terribly difficult, especially if you have a pattern that you can follow to increasingly add more and more to the mask, although I do find it very interesting.

I invite you to read the article...if for nothing else but to kill some quality geek time.
Lee

I think my head hurts now...

 


http://www.sqlservercentral.com/columnists/lEverest/2748.asp

Posted in:   Tags:
blog comments powered by Disqus

by Lee Everest, M.S.

Poll

Do you use Azure or cloud in your organization?



Show Results

Ads

Search


Month List

Calendar

«  February 2012  »
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011
View posts in large calendar

Tags

Disclaimer
The opinions, code, examples, et.al. expressed herein are my own personal opinions and do not represent my employer's view in any way, shape form, or fashion.  All code for demonstration purposes - no guarantees, either written or implied, are made.

© Copyright 2012 Lee Everest's SQL Server, etc. weblog