I’m working in one project where I need to execute large SQL script in SQL server, file size near about 2.5 GB. While I’m trying to open that script file in SSMS it doesn’t allow me to open that file it throws an error File is too large to open. Show I have tried to open script file with another editors i.e. notepad, notepad ++ as well but getting same error. We can open large file in Glogg editor with any file size WordPad also allow same, but it will take some time. Now question is How we can execute large SQL script? It is very sample Open Common Promat in Admin mode and type following command and Press enter key. sqlcmd -S \ -U -P -d -i Example: sqlcmd -S MyComputer-PC\MSSQLSERVER16 -U sa -P teamwork@1 -i "C:/Users/Amit /Downloads/dbScripts/script.sql" Output: SQLCMD is a viable option, but for such a huge script, I have never tested to confirm if it actually is capable of handling it or not. Also, I recommend to have Below is what I would recommend :
I guess, you have scripted your entire database along with schema and data and hence this mammoth size.
You wont be able to run it from SSMS or any GUI tools.
Never script out the entire database with data and schema. Instead -
Below is the script that will help you with Part 2.
How to import large SQL file in SQL Server?Here comes in handy the sqlcmd command line tool. It can import large . sql files, can be run from a batch script, installer, etc. How to use sqlcmd command-line tool to import large .
How do I run a SQL file in SSMS?In the Connect to Server dialog box, in Server name, select the name of your SQL server instance, and then click Connect. In Microsoft SQL Server Management Studio, on the menu, select File > Open > File. In the Open File dialog box, browse for the script file, and then click OK.
How to run big SQL script in MySQL?To run SQL script in MySQL, use the MySQL workbench. First, you need to open MySQL workbench. Now, File -> Open SQL Script to open the SQL script.
How to import .SQL file in SQL Server using command prompt?In this article , we will learn to export and import . SQL files with command line options.. -h / –host : host address to connect.. -u / –user : username of the account in the server.. -p / –password : to get the password prompt.. database : name of the database to import.. input. sql : the input . SQL file.. |