Can you add
Response.WriteLine("use " + SourceTable.Database.ToString());
as the first part of the CSLAStoredProcedure.cst template? Just to make sure if you run the script, it is generated into the correct database. :)
Will
Copyright (c) Marimer LLC