要启用“临时分布式查询”,我可以在 SQL 中运行以下语句。有谁知道如何从 PowerShell 启用?
sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
最佳答案
试试这个,替换 <SQL server>
和<database name>
使用适合您环境的正确参数:
$sql = '@
sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
'@
Invoke-SqlCmd -Query $sql -ServerInstance <SQL server> -Database <database name>
此处的语法突出显示无助于说明@' '@
表示“此处字符串”,允许所有字符直到 '@
因为换行符上的第一个字符表示字符串的结尾。
关于sql-server - 如何从 PowerShell 运行 sp_configure 'Ad Hoc Distributed Queries'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50223356/