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
Related
I was trying to create a new database (analyses_db) on a remote server from a sql file by the command:
pg_restore -d analyses_db byoryn_resource.sql
I received the error message
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.`
When I tried to follow the instruction: (from https://stackoverflow.com/a/40632316/15721796)
To reload such a script into a (freshly created) database named newdb:
$ psql -d newdb -f db.sql
I received:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I have no idea how to solve this, as a rookie. The SQL file should be alright as it is provided.
After the connection error being solved, I tried the command
sudo -u postgres psql db_name < 'file_path'
(from https://stackoverflow.com/a/26610212/15721796)
which works just fine.
Hope this can help someone who has the same problem.
Also some useful doc here https://www.postgresql.org/docs/9.1/backup-dump.html
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
I am trying to run the sql scripts from shell. My scripts are working fine. It is getting connected to database and applying the sql files. Only thing I am not able to understand is why the below error message is getting logged every time.
Error Message :
ERROR:
ORA-12545: Connect failed because target host or object does not exist
Shell Script:
/opt/ORACLE/app/oracle/product/11.2.0/client_1/bin/sqlplus -s <<eoj >>$LOG_FIL 2>&1
${DBUSER1}/${DBPASS}#${hostBillingDBSID}
#${SQLParm} $RPT_FIL
eoj
try the below.
Shell Script:
#let's include oracle installation in the PATH variable
export PATH=$PATH:/opt/ORACLE/app/oracle/product/11.2.0/client_1/bin
#now just use sqlplus, instead of full path reference.
sqlplus -s ${DBUSER1}/${DBPASS}#${hostBillingDBSID} <<eoj >>$LOG_FIL 2>&1
#${SQLParm} $RPT_FIL
eoj
The user/password(connection string) has to be passed as command line arguments to sqlplus.
I have a bat file that is using the bcp command to execute a stored procedure to a delimited file. When manually running the bat file, I get the following errors:
I'm using the -T parameter as I log into the database with Windows Authentication. Is there a setting I may need to change to fix this error?
The -S [DATABASE HOST NAME] argument needed to be passed to the bcp command.
I have a BCP operation in a batch command file. When there is an error in the BCP Operation I need to stop the processing and write the err msg in the log file
I've used to -e option to write the error message during a BCP operation to a err file. The err file is getting created in the location but does not contain any error message written to it.
My BCP statement is like this.
BCP DbName.dbo.tableName In FileLocation -e Errorfile -S ServerName -T -c
Is there a way to get the error level and then stop the processing?
Appreciate quick help.
The -m argument specifies max errors. "A row that cannot be copied by the bcp utility is ignored and is counted as one error. If this option is not included, the default is 10."
The -e argument specifies the file that the data is stored in that bcp cannot write to the output file.
The bcp utility is reporting the error to the DOS environment. Run bcp from a DOS script and capture/write the error from the DOS environment.