sql-server - 如何从 PowerShell 运行 sp_configure 'Ad Hoc Distributed Queries'?

标签 sql-server powershell octopus-deploy

要启用“临时分布式查询”,我可以在 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/

相关文章:

sql-server - 用于更新列中具有相同值的行的 T-SQL

visual-studio - Visual Studio 2019 - 使用 PowerShell 打开文件而不是解决方案资源管理器

powershell - 仅替换文件名中第一次出现的字符

sql-server - 有关 SQL Server Compact Edition 3.5 的基本问题

r - 机器学习服务器的 Max R 版本

多个分支机构的 TeamCity 最佳实践设置

asp.net-core - 启动设置.json、appsettings.json、web.config

azure - 从 TeamCity 部署构建

.net - 如何使用 .Net 实现 SQL Server 的 BCrypt?

powershell - Azure Devops发布管道中的参数 block 问题