Do you hate using bitwise operands? I do, a lot. I wrote the following function to try to minimize the need for using them. When testing 'status' variables in the 'sysobjects' table, for example, I decided there just had to be an easier way to see if bit 31 is set than asking if STATUS & 0x40000000 0.
There is now, using the following function:
IF dbo.f_bitmap (STATUS) LIKE '_1%'
The function accepts an integer (INT) value and returns a 32-char string consisting of '1's and '0's, representing (from left to right) the high order bit (32) and low order bit (1) settings of the integer.
Example: Determine if bit 19 of an integer variable is set.
IF RIGHT (dbo.f_bitmap (@integer), 19) LIKE '1%'
PRINT 'BIT 19 is set!'
ELSE
PRINT 'BIT 19 is not set'
A Normalization Primer
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.
2003-01-13
18,597 reads