SQL script too large directly in the database execution will prompt out of memory, we look at the generated script file will find that every 100 will have a go to separate, this is enough to say
After I have generated a script file Db.sql the structure of the database together with the data, I want to restore the database on another computer for programming testing. However, when I tried to execute the script on SQL Server Manager Studio, the other side told me that the file was too large to open. After a search, it is found that the following statements can be used by the command line, you can easily solve the problem. Note that if the script is too large, you can turn off the STDERR message to speed up execution.
Osql-u Sa-p-S (local) \sqlexpress-d trw-r-I Db.sql
Where SQLExpress is my local database server, TRW is the database name, and Db.sql is my script file. The command parameters for the osql tool are as follows:
osql [-u login ID] [-p password]
[-s server] [-H host name] [-E Trusted Connection]
[-D using Database name] [-L login Timeout value] [-t query timeout value]
[-H title] [-S column delimiter] [-w Column Width]
[-A packet size] [-e echo input] [-I allow quoted identifiers]
[-l list Servers] [-C command end] [-D ODBC DSN name]
[-Q "Command-line query"] [-Q ' command-line query ' and exit]
[-N Delete Numbering method] [-m error level]
[-R message sent to STDERR] [-V Severity level]
[-I input file] [-O Output FILE]
[-P print statistics] [-B Abort batch On ERROR]
[-x[1] Disable command, [exit with warning]]
[-o Disable the following using the old ISQL behavior]
Batch Processing
Automatically adjust console width
Wide Message
Default error level is-1 and 1
Use command-line CMD to navigate to the script file storage path First
SQL script file is too large to restore the database