There are times when you have a limited range of ids and these have to be re-used as they become available.The script lists the first missing id in a table.Note that this script works best for a table with a limited number of rows, say sub 100,000I tested this on a PIII 500MHz 256Mb RAM […]
Purpose: To compare two strings with a supplied operator and return true if the strings evaluate to true using the operator provided. This is useful for stored procs to use instead of dynamic sql. YAY! Allowing for the operator and value to be passed in as parms. So that the user on the front end […]
Sometimes people want a Stored Proc with optional parameters. A lot of times people will use a coalesce for this. The problem with optional paremeters is that the query plan will never be an exact mach for that specific query. ( You never know what paremeters are filled..... )To solve this problem look at the […]
Sometime one needs to perform an operation on all or selected databases on a server/instance. Microsoft provides undocumented store proc sp_MSForEachDb to achieve this. I use it for some clean up process as a SQL Job.
Occassionally you might want to convert a binary number into some printable string. This would allow you display some meaning fully numbers hex characters, instead of just some unreadable garbage. This script takes a binary field, of basically any length, and converts it, character by character, to a character string. The character string will contain […]
This simple script make a comparison between two given database. It compare: The table present in both database The data type, lenght, nullability, precision for each table. The object present in both database. The StoredProc is able to compare database across different server, simple make […]
This script returns the latest package log for the DTS package specified in the @package_name variable. The interface for viewing DTS package logs through Enterprise Manager is limited in the fact that it doesn't provide textual descriptions of the values for the Step Execute Status and Step Execute Results. This makes it difficult to trace […]
Have seen existing scripts to work out number of days in month. They tend to work out the month, and then whether it's a leap year.Another approach is to take the date passed in, find the first day of the next month, and then use Datadd to take off one day, ie: last day of […]