如何通过PowerShell将多个变量传递给SQL脚本?

时间:2017-06-12 21:11:58

标签: sql powershell powershell-v4.0

我有以下行来设置我的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 

这似乎不适用于多个变量。如果删除我尝试传递给SQL脚本的最后两个变量,SQL脚本将运行并运行。

在我的SQL脚本上,我有以下内容:

DECLARE 
    @currentDate NVARCHAR(25), 
    @filePath NVARCHAR(25),
    @sqlLoadErrors NVARCHAR(25)

SET @currentDate = $(fileDate) 
SET @filePath = $(filePath)
SET @sqlLoadErrors = $(sqlLoadErrors)

在PowerShell脚本中是否存在将变量传递给SQL脚本的错误?

1 个答案:

答案 0 :(得分:0)

试试这个:

public function __construct() {
    // Assign the CodeIgniter super-object
    $this->CI = & get_instance();
}

//Now for loading a model
public function addAudit($id_user,$description){
    $this->CI->load->model('your_model_name');
    $response_audit =  $this->CI->your_model_name->addAudit($id_user,$description);
            if($response_audit){
                log_message('debug',' Product --addAudit :: Response received from model'); 
                }else{
                log_message('debug',' Product --addAudit :: Response didnot received from model'); 
            }
}