gpt4 book ai didi

sql-server - Powershell x86 : Could not load file or assembly Microsoft. SqlServer.BatchParser

转载 作者:行者123 更新时间:2023-12-04 12:03:30 26 4
gpt4 key购买 nike

当我尝试做一个 invoke-sql来自 Powershell X86 的命令出现错误

invoke-sqlcmd -Query "SELECT 'HELLO!'" -ServerInstance Server -Database DB

invoke-sqlcmd : Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=15.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.



如果我从常规 x64 Powershell 提示符运行完全相同的命令,我不会收到错误
invoke-sqlcmd -Query "SELECT 'HELLO!'" -ServerInstance Server -Database DB
Column1
-------
HELLO!

这是在新建的 Windows 2016 x64 位服务器上:

操作系统名称 Microsoft Windows Server 2016 数据中心
版本 10.0.14393 内部版本 14393

我需要 x86 powershell 来运行使用旧版 32 位 ODBC 驱动程序的脚本,它还使用 invoke-sql命令也是如此。

最佳答案

正如其他一些评论中提到的,它可能与位版本有关。如果是这种情况,您可以使用 -RunAs32 标志启动一个作业,使其充当 32 位命名空间,然后通过 Receive-Job CMDlet 返回任何数据

# I am 64-bit land
$job_handle = Start-Job -RunAs32 -ArgumentList "Relevant Data" -ScriptBlock {
Param ( [string]$stuff_i_need )

# I am 32-bit land

return "Complete"
}

# I am 64-bit land (again)
$result = $job_handle | Wait-Job | Receive-Job
请注意,它将强制使用命名空间,因此需要传入任何相关数据

关于sql-server - Powershell x86 : Could not load file or assembly Microsoft. SqlServer.BatchParser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54220014/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com