I'm trying to use bat file/CLI to run SQL script against certain Oracle database with following syntax:

sqlplus -L user_name/database_name@Password @d:\my_bat_file\sql_script.sql

If I run this following error is returned:

ORA-12154: TNS:could not resolve the connect identifier specified

SP2-0751: Unable to connect to Oracle. Exitig SQL*Plus

At the same time tnsping database_name works fine & corresponding connection configuration strings are present in tnsnames.ora

Moreover if I type commands manually in a following way:

sqlplus /nolog
connect user_name@databasename

I can connect to the database too. Any idea why I'm getting error when trying to use command I mentioned in beginning & how to fix it?

P.S. I'm doing this from Windows Server 2003 SP2 box with Oracle client v10 installed.


I've posted this on dba.stackexchange.com - and received answer promplty:


Basically the problem was wrong syntax in bat file: Wrong command line:

sqlplus -L user_name/tns_alias@Password @d:\my_bat_file\sql_script.sql

Correct one:

sqlplus -L user_name/Password@tns_alias @d:\my_bat_file\sql_script.sql

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.