These are utility functions for SQL Server 2000. Some of the functions can be used on their own. Functions like IEEE32toReal and IEEE64ToFloat require the use of the other functions.
Click here to download the SQL scripts.
1) Scalar function to right pad Ascii or Unicode strings.
2) Scalar function to left pad Ascii or Unicode strings.
3) Inline table-valued functions to return running jobs from msdb based on information from master..sysprocesses.
4) Table-valued function that splits a string based on a delimiter. It returns a table of values with their position. This function works on Ascii or Unicode strings.
5) Table-valued function that splits an Ascii string. Slightly different implementation of the above function.
6) Scalar function that returns a string of bits for integer or binary values.
7) Inline table-valued function "BytesToBits" to get a range of bits from a 8-byte binary value.
8) Scalar function "BitsToFloat" that returns sum of powers of 2 or inverse powers of 2 for a 8-byte IEEE 754 format binary value. The IEEE 754 format of the binary value can be obtained by doing cast( floatval as binary(8) ). This function is used by the utility functions that converts IEEE 754 format binary value to the floating point value. Note that SQL Server doesn't support supporting binary values to real/float directly.
9) Scalar functions to convert binary values of floating point numbers stored in internal format like in memory where the sequence of bytes are reversed. These functions convert the bytes into the IEEE 754 format with the bits numbered from left to right for convenience.
10) Table-valued functions that return the binary ranges for single and double-precision floating point numbers. The binary values are in IEEE 754 format.
11) Scalar function to convert 4-byte single-precision binary value in IEEE 754 format to real. The sp_ParseTrcShowStats stored procedure in the UtilitySPs page shows how this function is used to obtain real value from binary format.
12) Scalar function to convert 8-byte double-precision binary value in IEEE 754 format to float. The sp_ParseTrcShowStats stored procedure in the UtilitySPs page shows how this function is used to obtain float value from binary format.