I want to connect to sybase than execute a file.sql
I tapped this command:
sql -U Login -P MotDePasse -S ServeurASE -d NomDeLaBase -i Script.sql -o JournalDErreur.log
I also tried
isql -U Login -P MotDePasse -S #IPserveur:Port -d NomDeLaBase -i Script.sql -o JournalDErreur.log
and I have the error :
"La commande sql n'est pas reconnue'
Can u help please?
I have installed JTDS and sql (pip install) but it doesn't work
Assuming you're trying to connect to a Sybase ASE database, and you're using the isql command line utility that comes with ASE (or the Sybase SDK), the correct isql format is:
isql -U <login> -P <password> -S <host_or_ipaddr>:<port> -D <dbname> -i <input_script> -o <output_file>
So updating your example we get:
isql -U Login -P MotDePasse -S IPserveur:Port -D NomDeLaBase -i Script.sql -o JournalDErreur.log
I can't speak for your sql example as I'm not familiar with that tool let alone its input parameters.
Related
I have 2 SQL queries which I execute to get the size of table and number of records in a table
[~] mysql -u <username> -h <hostname> -p <db_name> -e "SQL_Query 1" > out.txt
[~] mysql -u <username> -h <hostname> -p <db_name> -e "SQL_Query 2" > out1.txt
How can I wite shell script to execute these queries
This is a shell script, supported by bash / sh, and probably others:
#!/bin/sh
mysql -u <username> -h <hostname> -p > output.log <<EOF
SELECT query 1 ...;
SELECT query 2 ...;
EOF
Note: You'll need to address the password entry issue, which can be done in several ways.
You can also enter your SQL in a file (file.sql) and redirect input from that file:
mysql -u <username> -h <hostname> -p < file.sql > output.log
How can i dump the .sql file into remote postgres machine!
Will the pg_restore will work for it to dump sql file. Please help
Code:
pg_restore -h 192.168.0.190 -p 5432 -d postgre -U postgres C:/home/mydump.sql
This worked for me
psql -h 192.168.0.190 -U postgres -p 5432 -d postgre < mydump.sql
I am new in SQL Server, can somebody help me to execute SQL query from command-line tool in SQL Server?
use below command prompt query to execute filename.sql using SQLCMD.
SQLCMD -d <database-name> -U <User-name> -P <Password> -i filename.sql -o output.txt
-d = Database Name
-U = User Name
-P = Password
-i = Filename.sql
-o = output.txt
-E = Windows Authentication mode if you specify this need to skip -U & -P parameters.
How can I connect to SQL Server from command prompt using Windows authentication?
This command
Sqlcmd -u username -p password
assumes a username & password for the SQL Server already setup
Alternatively how can I setup a user account from command prompt?
I've SQL Server 2008 Express on a Windows Server 2008 machine, if that relates.
You can use different syntax to achieve different things. If it is windows authentication you want, you could try this:
sqlcmd /S /d -E
If you want to use SQL Server authentication you could try this:
sqlcmd /S /d -U -P
Definitions:
/S = the servername/instance name. Example: Pete's Laptop/SQLSERV
/d = the database name. Example: Botlek1
-E = Windows authentication.
-U = SQL Server authentication/user. Example: Pete
-P = password that belongs to the user. Example: 1234
Hope this helps!
Try This :
--Default Instance
SQLCMD -S SERVERNAME -E
--OR
--Named Instance
SQLCMD -S SERVERNAME\INSTANCENAME -E
--OR
SQLCMD -S SERVERNAME\INSTANCENAME,1919 -E
More details can be found here
This might help..!!!
SQLCMD -S SERVERNAME -E
After some tries, these are the samples I am using in order to connect:
Specifying the username and the password:
sqlcmd -S 211.11.111.111 -U NotSA -P NotTheSaPassword
Specifying the DB as well:
sqlcmd -S 211.11.111.111 -d SomeSpecificDatabase -U NotSA -P NotTheSaPassword
type sqlplus/"as sysdba" in cmd
for connection in cmd prompt
here is the commend which is tested
Sqlcmd -E -S "server name" -d "DB name" -i "SQL file path"
-E stand for windows trusted
If you are running Linux, Mac OS or Windows, you can use MSSQL-CLI. Read the tutorial at https://www.mssqltips.com/sqlservertip/5298/new-interactive-command-line-tool-mssqlcli-for-sql-server/
With either of 2 commands below, I could log in SQL Server 2019 Express through Windows authentication:
sqlcmd -S DESKTOP-5K4TURF\SQLEXPRESS -E
sqlcmd /S DESKTOP-5K4TURF\SQLEXPRESS /E
I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user sa and its password.
How would the bat file be?
How can I specify in the script the password and that I use in SQL Express?
Take a look at the sqlcmd utility. It allows you to execute SQL from the command line.
http://msdn.microsoft.com/en-us/library/ms162773.aspx
It's all in there in the documentation, but the syntax should look something like this:
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "DROP TABLE MyTable"
You can do like this
sqlcmd -S <server Name> -U sa -P sapassword -i inputquery_file_name -o outputfile_name
From your command prompt run sqlcmd /? to get all the options you can use with sqlcmd utility
If you use Integrated Security, you might want to know that you simply need to use -E like this:
sqlcmd -S Serverinstance -E -i import_file.sql
Feedback Guys, first create database example live; before execute sql file below.
sqlcmd -U SA -P yourPassword -S YourHost -d live -i live.sql
Firstly create an empty database in SQL server, then run this command.
sqlcmd -s ServerName -d CreatedDatabaseName -i ScriptFileName.sql
ScriptFileName should be with a complete path like "D:\Folder Name\ScriptFileName.sql".
You can also use -u and -p if you have userName and password in your sql server.
First set the path of MYSQL in Environment variable-> System variables-> Click on Path-> Add -> "C:\Program Files\MySQL\MySQL Server 8.0\bin"
Open cmd-> navigate to the folder which has the sql script-> type as below ->
mysql --user=root -p < employees.sql -> Enter the password which was set during MYSQL setup-> hit enter
Done.
CMD Screenshot after it worked form me