Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

“Argument null or empty” errors in Powershell function using Invoke-SQLCmd

$
0
0

Hi Guys,

I have the following scrip :

sqlps -NoLogo -Command{invoke-sqlcmd -InputFile "D:\MyProject\CreateDatabase.sql"}

Which work well, but when when i want to replace the imput file by a variable like that :

[string] $ScriptFilePath="D:\MyProject\CreateDatabase.sql"

sqlps -NoLogo -Command{invoke-sqlcmd -InputFile $ScriptFilePath }

I have the following error : Invoke-Sqlcmd : Cannot validate argument on parameter 'Database'. The argument is null or empty. Supply an argument tha t is not null or empty and then try the command again.

It's crazy, where is the problem?

Sincerly yours


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>