I have a bigger sql text file (powerpro.sql --> 350MB) to be uploaded to phpmyadmin database named powerpro-new.
So, I used the following command in windows
C:\mysqldump -uroot -p powerpro-new > "C"\powerpro.sql"
But, received the following error.
'mysqldump' is not recognized as an internal or external command,
operable program or batch file.
What may be the error. Can anyone help me pls?
You should navigate to your mysql installation directory in cmd. The default installation path (MySQL Server 5.6) is:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqldump.exe -uroot -p powerpro-new > "C"\powerpro.sql"
If you don't know where you installed MySQL server you can search mysqldump file by using following command:
C:\>dir /S /P mysqldump.exe
Related
I want to run 20 SQL scripts from a folder on a database in SQL Server.
My SQL Server is called SQL_SERVER_1, my database is called SQL_DATABASE_1.
I have 20 SQL files (01 - file, 02 - file, 03 - file, etc) in a folder c:\Users\Me\Desktop\New Folder.
I'm unable to get the syntax correct for this.
On a separate note: is there any way I run all the files inside the folder consecutively one after the other, without having to write the command for every file?
Sure you can:
Locate SQLCMD.EXE, depends on version of SQL server
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -U <UserName> -P <Password> -S (local)\SQLExpress -i "c:\Users\Me\Desktop\New Folder\01 - file.sql"
To run it for all files check ForFiles.
forfiles -M *.sql -C "cmd /c <your path to SQLCMD>SQLCMD.EXE <your connection parameters> #Path "
is it possible to create a batch file which run from local computer to execute a query in production server, production server can be accessible only through remote connection. ? if not possible please suggest some ways,
Requirement: Need a batch files to get query results from production server?
Try like this,
Step-1:
Enter the below five lines and Save this as execute.bat file
set /P TargetServer=Enter Target DB Server IP:
set /P TargetDb=Enter Target DB Name:
set /P UserName=Enter UserName:
set /P Passwd=Enter Password:
sqlcmd -S %TargetServer% -U %UserName% -P %Passwd% -d %TargetDb% -i MyScript.sql -o MyOutput.txt
Step-2
Provide your sqls in this file and save it as MyScript.sql
select *from tablename
Step-3
Place execute.bat and Myscript.sql files in a folder then double click the execute.bat file. Your output of the MyScript.sql is saved in MyOutput.txt file.
Create a Batch file and Keep it production server itself by scheduling a task Task Scheduler (Windows assumed OS). So that no need of Remote access to Production server every time.
This is my suggestion from what I understood from your question.
I haver a sample GTFS data file I am attempting to load to Azure. The command I am using is:
bcp %fullTablePath% in %data_dir% -f %format_file% -S %server% -U %username% -P %password% -k -F %first_row%
where the parameters are replaced accordingly.
When I execute the command, I get:
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 11.0]Unable to open BCP host data-file
This is not a file naming issue because the file is indeed there. If I deliberately spell the file incorrectly, I get the same error. Sounds like a permission issue but who do I grant what permission?
If you see this error in batch file but not from PowerShell check that your
%fullTablePath% or %data_dir% variables are full qualify path/absolute path and not relative path as PowerShell and Batch may have different default path settings which may give you the error of:
Unable to open BCP host data-file
Using SSMS 2008 I am able to generate a script for a database with huge amounts of data in file ABC.sql on my desktop.
The database has approx. 9 GB of data so I'm unable to open the file. Is there any way to execute the script?
When I try to open it in SSMS I get an error:
The operation could not be completed. not enough storage is available to complete this operation
The template specified cannot be found. Please check that the full path is correct
SQL Server offers 2 command prompt features that can se used for executing large queries - osql (will be removed in future), and sqlcmd
osql is located in the Tools\Binn subfolder. To execute a SQL script:
Start the Command Prompt
Navigate to the folder where the osql utility is located
Run the command in the following format:
osql –H <workstation name> -S <server_name[\instance_name]> -U <user login ID> -P <login password> –i <full path to script>
To execute the large.sql file located in the D:\test, against the Central database on the SQL Server instance Dell\SQL2012, as an sa with the 'sqladmin' password, run the following command:
osql -H Dell -S Dell\SQL2012 -i D:\test\large.sql -U sa -P sqladmin
The sqlcmd command line utility is also located in the SQL Server’s Tools\Binn sub-directory. To execute a SQL script:
Start the Command Prompt
Navigate to the folder where the sqlcmd utility is located
Run a command in the following format:
sqlcmd –S <server name> -d <database name> -i <full path to script> -U <user login ID> –P <login password>
To execute the same as above, run the following command:
sqlcmd -S Dell\SQL2012 -d Central -i D:\test\large.sql -U sa –P sqladmin
Start the sqlcmd Utility
Run Transact-SQL Script Files Using sqlcmd
I use sqlcmd to execute large SQL files.
You can generate script of your database by RightClick on your database Tasks>GenerateScripts> click next on Generate and Script window Check on select specific table choose tables you want Press next Click on Advance option on end of General Category select Type of data to script now choose which kind you want your database to.
Scheme Only: Means this script will create your database.
DataOnly:If you have created database and table this will insert data into it.
Press ok then Next.
Your file is by default save in
C:\Users[UserName]\Documents\ .
I have just got a new work PC from running Windows 7. I have installed SQL Server 2008 and I have a batch file that runs an OSQL command as follow:
osql -S MyServer -E -d MSDB -n -o results.txt -i MyScript.sql
For some reason it is giving me exception below:
Specified driver could not be loaded due to system error 126: The specified module could not be found. (SQL Server Native Client 10.0, C:\Windows\system32\sqlncli10.dll).
I am not sure what the issue is and I have even tried to run the batch file using 'Run as administrator'.
OSQL is being deprecated; I would consider converting your code to use sqlcmd or PowerShell. However if you're missing SQL native client you might consider adding it. You can download the sqlncli.msi file for your platform from this URL (more than halfway down the page).