I have the following line to set up my sql cmd.
$mySqlCmd = "sqlcmd -S $server -U $username -P $pwd -d $dbname -o $lis -i $sqlScript -v fileDate = $fileDate, filePath = $filePath, sqlLoadErrors = $sqlLoadErrorPath"
Invoke-Expression $mySqlCmd
This doesn't seem to work for more than one variable. The SQL script runs and works if I remove the last 2 variables I am trying to pass into the SQL script.
On my SQL script I have the following:
DECLARE
@currentDate NVARCHAR(25),
@filePath NVARCHAR(25),
@sqlLoadErrors NVARCHAR(25)
SET @currentDate = $(fileDate)
SET @filePath = $(filePath)
SET @sqlLoadErrors = $(sqlLoadErrors)
Is there something wrong being done in the powershell script to pass variables to an SQL script?