0

I'm trying to execute a sql script from powershell using the following command:

sqlplus username/password@tnsnamesalias 'path to my sql file.sql'

If I run the command without the script path, I can connect to the database and execute commands. If I include the script path (which includes spaces) then I just get the sqlplus help text and no changes are made to the database. My sql script is finished with END; and /

What am I doing wrong?

2 Answers 2

2

I believe you need to add the @ sign before the path:

sqlplus username/password@tnsnamesalias @'path to my sql file.sql'
Sign up to request clarification or add additional context in comments.

2 Comments

So, I tried that and I get the following error: No characters are allowed after a here-string header but before the end of the line. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedCharactersAfterHereStringHeader
I needed to escape it with ` thats got it, thank you! So sqlplus username/password@tnsnamesalias `@'path to my sql file.sql'
2

You have forgotten "@" symbol and the apostrophes are wrong here.

This works for me for executing a "test script.sql" file

sqlplus .... "@test script.sql"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.