How to execute a 3 GB sql file - sql

i have a 3GB sql file and i can't open directly on management studio,so,i have to split the file and execute the parts.but,how i'll split the file? or execute directly without outOfMemory exception?
i'm using SQL SERVER 2014 and i didn't have sucess restoring the .sql with cmd..

I have faced this before..Use sqlcmd utility.. very easy to use.. in this case you just have to give the path of one big script file with few other parameters. Refer to microsoft documentation.
Hope that helps

that sucks. you should be able to load the .sql file via command line. this is how most data warehousing companies load large db/sql files in order launch databases. this should NOT be opened with any IDEs and loading it via command line is the only way it's done.
if I were you I'd try to load the file via cmd again because that's the way to do it.

Related

How to open a very big file in Microsoft SQL Server Management Studio 2014?

I have a file about ~9GB. It's a file extracted from an old MS SQL server and I need to import it to a new one. The file has no extension.
When I try to open it through Microsoft SQL Server Management Studio 2014 I get the following error:
First of all, if you want to open a large file to read it, which i assume that it is not the case, pick one of the text editors from this post:
Text editor to open big files
And in case you want to execute really big SQL scripts, you will have to do it through the Windows CMD (or Bash in case you are using Ubuntu for example) using SQLCMD, have a look at this:
Execute large scripts using SQLCMD
I hope this is what you are looking for!

How to run .sql file in Oracle SQL developer tool to import database?

I have exported database from Oracle SQL developer tool into .sql file. Now I want to run this file which is of size 500+ MB.
I read about running scripts here, but I didn't understand the way. Is there any command or query by which we can run this sql script by providing path?
You could execute the .sql file as a script in the SQL Developer worksheet. Either use the Run Script icon, or simply press F5.
For example,
#path\script.sql;
Remember, you need to put # as shown above.
But, if you have exported the database using database export utility of SQL Developer, then you should use the Import utility. Follow the steps mentioned here Importing and Exporting using the Oracle SQL Developer 3.0
You need to Open the SQL Developer first and then click on File option and browse to the location where your .sql is placed. Once you are at the location where file is placed double click on it, this will get the file open in SQL Developer. Now select all of the content of file (CTRL + A) and press F9 key. Just make sure there is a commit statement at the end of the .sql script so that the changes are persisted in the database
You can use Load function
Load TableName fullfilepath;

How to convert .sql file into .mdf file?

I have a .sql file. How can I convert this .sql file to a .mdf SQL Server database file?
I know that .sql file is nothing but a script file if I open the .sql file in notepad it will show me the db code I can simply copy those code and paste into SQL Server Management Studio.
Is there any other way to convert .sql to .mdf file?
Unless your SQL file contains the script to create a database, your question wouldn't make any sense. If it does contain such script you need an environment to execute it. There are many tools that will allow you to do that. For example, many IDE tools that integrate with SQL Server have such capability.
So to answer your question: it is impossible to convert SQL file to MDF. You, however, can sometimes use an SQL file to build MDF.

After using SSMS's Generate Scripts sqlcmd won't run it

I tried backing up my database using SSMS Generate Scripts options. This produces a rather large file that SSMS won't run (memmory limit).
I tried then running this script using sqlcmd, but I get a syntax error.
I read that sqlcmd mode is different and I do not wish to manually remove the errors (there are potentially alot of them).
Is there a way to generate the script so it will obey the rules of sqlcmd or vice versa?
If you are doing a backup with data, why don't you just right-click database - select tasks and backup and backup to a file?
Other than that, it would be hard to tell you what the error is without knowing what error you are getting.

How to run multiple .sql files in Eclipse DTP

I've a list of .sql script files to create Stored Procedures which I'm using the Eclipse DTP to develop. Currently to create/update all these Stored Procedures, I've to open & run
one by one from the Data Perspective.
Is there a way to create a batch file that run the scripts along the lines of
run createSP1.sql
run createSP2.sql
...
run createSPn.sql
and run it in the Eclipse DTP to avail of the DB connection defined there?
why not just create a batch file that merges all of your .sql files together into a single procs.sql file as part of the build process. I don't know what platform you're running on but in Windows you could have a .bat file that does something like this:
type *.sql > proc.sql
then to apply it to the database, why not do it outside Eclipse and connect to the database via the command line. You could bundle this all up as a single batch file that gets the latest version of your stored procedures from source control, merges them into a single file and then applies it to the database.
Part I
As far as I know the developers of Eclipse DTP
have not yet implemented a command line SQL execution
interface through the Eclipse console view.
See the following URL on the eclipse DTP developer forum
http://dev.eclipse.org/newslists/news.eclipse.dtp/msg00304.html
Part II
While the Eclipse DTP people are working on it,
you can use a database specific tool to load
a master SQL file (all SQL proc files
appended together)
There are database specific console
tools that will load your master SQL file
command line.
(ie. SQL*Plus for Oracle, ij for Apache Derby)
Part III
An improvement over DOS batch is using Cygwin bash
or python or perl to merge all of your sql files
together into a master file.
I found that the text processing tools available
in UNIX (awk,sed,cat...) are great for this sort
of thing.