Execute SQL*Plus from PowerShell

落花浮王杯 提交于 2019-12-06 15:11:19

I found the solution myself

I use cmd.exe /c and alex.ps1 is now

$cmd = "cmd.exe";
$args = "/c sqlplus user/password@server/sid @C:\temp\SQL\alex.sql";
&$cmd $args;

Hope this help.

To offer an alternative solution to @Alex Yeung, you can simply use the PowerShell & call command to run the statement outright, without the need to use cmd.exe:

&sqlplus user/password@server @C:\path\script.sql

Consider adding the following to the bottom of your script file to ensure SQLPlus is closed when it has finished running:

DISCO -- Disconnect
EXIT -- Exit SQLPlus
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!