• Nice article. I have been working on a table based code generator and this may actually allow me to speed things up a little.

    Code does need tweaking for 2005. The setup section should read something like below to pass the execution.

    declare @DBName varchar (20)

    declare @TableSchema varchar (20)

    set @DBName = PARSENAME (@TableName, 3)

    set @TableSchema = PARSENAME (@TableName, 2)

    set @TableName = PARSENAME (@TableName, 1)

    if @DBName is not null

    and @DBName != DB_NAME()

    begin

    print 'Cannot run this on DB ''' + @DBName + '''. Must be run on current DB.'

    return;

    end

    -- Set up some values for displaying the results.

    declare @Y varchar (10)

    set @Y = ' y'; -- Spacing is for nicer look.

    declare @Empty varchar (1)

    set @Empty = '';