I am trying to generate Schema with 90000 tables from Generate Script option but after sometime it returns error. DB size 600 GB. What's the other way around?

Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptPub‌​lishException: An error occurred while scripting the objects. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Xml.XmlTextReaderImpl.InitStreamInput(Uri baseUri, String baseUriStr, Stream stream, Byte[] bytes, Int32 byteCount, Encoding encoding) at System.Xml.XmlTextReaderImpl..ctor(String url, Stream input, XmlNameTable nt) at System.Xml.XmlTextReader..ctor(Stream input) at


2 Answers 2


You can try with:

Visual Studio

  • Create a new Sql Server project.
  • Right click on the project and select Import - Database

You'll get an structure like this:

enter image description here

Third party tools like:


Script SQL objects and data into scripts and deployment packages


I've not tested it.


SQL Power architect

Has a community edition.


Try to use SSIS which is the simplest method.

Or generate the script for each table in a separate .sql file. then create a batch file to execute one by one.

  • 1
    Another option is using Smo Scripter via Powershell.
    – Dan Guzman
    Commented Apr 11, 2017 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.