如何从 PowerShell 运行 sp_configure 'Ad Hoc Distributed Queries'?
How to run sp_configure 'Ad Hoc Distributed Queries' from PowerShell?
要启用 'Ad Hoc Distributed Queries' 我可以 运行 在 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>
这里的语法高亮并没有帮助说明 @' '@
表示 'here string',它允许 '@
之前的所有字符,因为换行符的第一个字符表示结束字符串.
试试这个脚本
$query = "
sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
"
Invoke-SqlCmd -Query $query -ServerInstance <Your Server Name>
要启用 'Ad Hoc Distributed Queries' 我可以 运行 在 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>
这里的语法高亮并没有帮助说明 @' '@
表示 'here string',它允许 '@
之前的所有字符,因为换行符的第一个字符表示结束字符串.
试试这个脚本
$query = "
sp_configure 'show advanced options', 1
reconfigure
GO
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
"
Invoke-SqlCmd -Query $query -ServerInstance <Your Server Name>