2

Closed

StackOverflowException when scripting large database

description

We have a very large database that needs to be scripted out (about 3000 objects). The regular Sql 2005 tools for this are not very accurate, so I'd like to use yours instead. I've tried it a few times, and it seems to get part of the way through generating a script, then errors out because of a StackOverflowException. Is there any fix for this? Thanks for all the work on this tool!
Closed Mar 16, 2011 at 5:35 AM by ivanjh
Resolved with changeset 74673.

comments

codeasice wrote Mar 23, 2009 at 3:39 PM

I'm receiving the same error. I've tried various parameters, including "/ot:Tree /ssq". I think this will be an excellent tool, if I can get it to work!

Thanks

ivanjh wrote Mar 16, 2011 at 5:18 AM

This is most probably caused by a circular reference, and not the number of objects in the DB.

Example: Two tables, A & B. A has a foreign key into B, and B has a foreign key into A.
Question: What order do you script these two tables - A followed by B, or B followed by A?
Answer: Neither. You need to create the tables for BOTH A & B, and then the constraints for BOTH A & B.

This is a completely valid scenario, and one that should be catered for - but it will introduce some complexity (separate files for tables & foreign keys).
For the moment, I've just submitted a code change that will detect the situation (warn and not overflow), but you won't be able to recreate from scriptc as it may reference an object which won't exist yet.

This is available in ExportSQLScript.20110316beta2.zip

wrote Mar 16, 2011 at 5:35 AM

wrote Feb 14, 2013 at 2:49 AM

wrote May 16, 2013 at 6:53 AM