• The master, NewDB, and OldDB are all SQL_Latin1_General_CP1_CI_AS.

    I restored my template database (this is the one that we restore to setup new sites) and the header said it was version 661 which is SQL 2008 (NOT R2). I am now running SQL 2008 R2 first release, but I also tested on SQL 2012. This restored template database had the issue of only the last column being returned for existing tables. New tables worked. And then after I added the (SELECT ) to sp_getddl returned all columns.

    ELSE (SELECT ' CONSTRAINT ' + quotename(def.name) + ' DEFAULT ' + ISNULL(def.[definition] ,''))