encoding error powershell

  • Hello everyone

    I need to run existing * .sql files in a directory through powershell

    the script is the following

    Start-Process powershell.exe -Credential "A1\amdev"

    IF (!(Get-Module -Name sqlps))
    {
    Write-Host 'Loading SQLPS Module' -ForegroundColor DarkYellow
    Push-Location
    Import-Module sqlps -DisableNameChecking
    Pop-Location
    }


    $localScriptRoot = "C:\TSQL\Insertion Distind_importation_tampon"
    $Server = "DWH"
    $scripts = Get-ChildItem $localScriptRoot | Where-Object {$_.Extension -eq ".sql"}

    foreach ($s in $scripts)
    {
    Write-Host "Running Script : " $s.Name -BackgroundColor DarkGreen -ForegroundColor White
    $script = $s.FullName
    Invoke-Sqlcmd -ServerInstance $Server -InputFile $script
    }

    the execute script with this error

    Sans titre

    and v."Numéro Version" = echantillon.MaxNumeroVersion

    while through ssms it spends corectly

    Sans titre

     

    Who has an idea how I can correct this encoding error

  • Check the value of SET QUOTED_IDENTIFIER for the connection with PowerShell, or just alter your script so that it uses [ ] instead of " " for identifiers.

    John

    John

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply