T-SQL

To find the next available ID

  • Script

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 […]

2002-12-09

110 reads

Dynamic String Compare (W/O the dynamic sql)

  • Script

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 […]

2002-12-07

447 reads

Stored Proc with optional parameters

  • Script

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 […]

2002-12-06

419 reads

Converting Binary data to a Hex Character String

  • Script

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 […]

2002-11-07

443 reads

sp_DBCompare

  • Script

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 […]

2002-10-31

768 reads

Latest DTS Package Log

  • Script

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 […]

2002-10-22

609 reads

Get Number of Days in month

  • Script

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 […]

4 (1)

2002-10-17

393 reads

Blogs

Daily Coping 29 May 2020

By

I’ve started to add a daily coping tip to the SQLServerCentral newsletter and to...

Custom Quarantine PoSh Prompt

By

Since I’ve been quarantined at home and working in my office, every day is...

TIL: Get-DbaErrorLog

By

Ed: SQLDork is a Junior DBA on the team here, learning the DBATools in...

Read the latest Blogs

Forums

Daily Coping 29 May 2020

By Steve Jones - SSC Editor

Today’s tip is today link your decisions and choices to your purpose in life....

Week Ending Thursday, can some one tweek my code?

By bark01

What I have missed from this code? I'm trying to show the DateTimeRaised field...

The Matchbox Database

By Phil Factor

Comments posted to this topic are about the item The Matchbox Database, which is...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers