Gerard's codebase

This is a personal repository of code snippets and information.

Over the years I have generated lots of little sub programs and stored away acres of useful code snippets. The problem is always to locate them.

Even more time wasting is forgetting how to do simple things when you havnt developed in an environment for a few years (or even a few months)

My new years resolution is to start putting them up in a common place as I produce them. (thanks google)

They are handy for me and, with a bit of a clean up and documentation, they might be handy for others if they wander in here.

Gerard 2008

Tuesday, April 14, 2009

List Object in SQL Db - Specific Examples

The generic SQL found here can be tweaked to do almost anything


The following are more specific examples
-- This snippet searches for columns named like %product% 
SELECT
o.name AS TableName,c.*
FROM
sysobjects AS o
INNER JOIN syscolumns AS c
ON c.id = o.id
WHERE
(o.type = 'U' OR o.type = 'S')
AND c.name LIKE '%product%'

Thursday, April 2, 2009

Deleting Restoring Databases

I keep forgetting this and it cost me time as the job runs forever and will not cancel.
With logshipping you sometimes need to delete a restoring database that has failed.
Remember that you need to uncheck the "delete backup and restore" checkbox