小编Rav*_*obo的帖子

VS代码PowerShell扩展intellisense非常慢

VS Code PowerShell intellisense对我来说突然变得非常缓慢.它工作正常几天.我卸载了所有扩展,但PowerShell除外.

以下是有关VS代码的详细信息.

Version: 1.28.2 (user setup)
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:23:51.859Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
Run Code Online (Sandbox Code Playgroud)

以下是PowerShell的用户设置:

"powershell.bugReporting.project":" https://github.com/PowerShell/vscode-powershell ","powershell.codeFolding.enable":true,"powershell.codeFormatting.alignPropertyValuePairs":true,"powershell.codeFormatting.ignoreOneLineBlock ":true,"powershell.codeFormatting.newLineAfterCloseBrace":true,"powershell.codeFormatting.newLineAfterOpenBrace":true,"powershell.codeFormatting.openBraceOnSameLine":true,"powershell.codeFormatting.preset":"Custom","powershell.codeFormatting" .whitespaceAfterSeparator ":真实的, "powershell.codeFormatting.whitespaceAroundOperator":真实的, "powershell.codeFormatting.whitespaceBeforeOpenBrace":真实的, "powershell.codeFormatting.whitespaceBeforeOpenParen":真实的, "powershell.debugging.createTemporaryIntegratedConsole":假的," powershell.developer .bundledModulesPath":"","powershell.developer.editorServicesLogLevel":"Normal","powershell.developer.editorServicesWaitForDebugger":false,"powershell.developer.featureFlags":[],"powershell.developer.powerShell ExeIsWindowsDevBuild":false,"powershell.developer.powerShellExePath":"","powershell.enableProfileLoading":true,"powershell.helpCompletion":"BlockComment","powershell.integratedConsole.focusConsoleOnExecute":true,"powershell.integratedConsole.showOnStartup ":true,"powershell.powerShellAdditionalExePaths":[],"powershell.powerShellDefaultVersion":"","powershell.powerShellExePath":"","powershell.scriptAnalysis.enable":true,"powershell.scriptAnalysis.settingsPath":" ","powershell.startAutomatically":true,"powershell.useX86Host":false

有人有建议吗?

powershell intellisense visual-studio-code

6
推荐指数
1
解决办法
1184
查看次数

使用PowerShell在SQL Server DB中插入字符串值.

我有一个很长的值列表需要插入单列SQL服务器表中.我使用以下代码.但是,这需要很长时间.有没有更简单的方法来实现这一目标?

$list = 'aaa','bbb','cccc','ddddd','eeeee','ffff'....

    foreach($i in $list) {
        $sql ="if not exists (select 1 from [table_nm] where column_nm = '$i' ) 
            begin 
              insert table_nm
              select '$i'
            end
            " 

        Invoke-Sqlcmd -ServerInstance $server -Database db_nm -query $sql               
        }
Run Code Online (Sandbox Code Playgroud)

sql powershell sql-server-2008

4
推荐指数
1
解决办法
3万
查看次数

Invoke-SQLCMD 无法在 PowerShell 中运行多个 SQL 语句

我无法从 Invoke-sqlcmd 运行 2 个 SELECT 语句。

$sql ="
select SERVERPROPERTY('ProductVersion') Version
select SERVERPROPERTY('ProductLevel') ServicePack, SERVERPROPERTY('edition') Edition"
    
$server = 'SomeServerName'    
Invoke-Sqlcmd -ServerInstance $server -Query $sql 
Run Code Online (Sandbox Code Playgroud)

只有第一个 TSQL 语句返回结果。

注意:我可以重写 TSQL 来生成一条语句。这不是重点。原始脚本有多个 TSQL 命令。另外,我可以为每个语句执行单独的 invoke-sqlcmd 调用。但是,我试图了解这是否是 invoke-sqlcmd 的限制。

这是预期的行为吗?

太感谢了。

sql-server powershell

3
推荐指数
1
解决办法
3385
查看次数

在更改跟踪中禁用列更新

我使用以下命令启用了更改跟踪:

ALTER TABLE Table1 ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON) 
Run Code Online (Sandbox Code Playgroud)

但是,我注意到这TRACK_COLUMNS_UPDATED = ON会产生开销,而且我的开发团队没有使用该功能。我该如何设置TRACK_COLUMNS_UPDATED = OFF?我不想禁用/启用更改跟踪,这可能会导致更改跟踪数据丢失。

我期待以下内容:

ALTER TABLE Table1 ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF)
Run Code Online (Sandbox Code Playgroud)

但这不是正确的语法。

t-sql sql-server change-tracking sql-server-2008

2
推荐指数
1
解决办法
968
查看次数

如何使用 PowerShell 跨 Azure 订阅列出资源组?

我正在编写一个 PowerShell 脚本来列出 Azure 订阅中的资源组。

Get-AzureRmSubscription | 
select -ExpandProperty name |
 % { 
     Get-AzureRmResourceGroup | select -ExpandProperty resourcegroupname
 }
Run Code Online (Sandbox Code Playgroud)

此代码有效。它返回这样的结果。

Resource group 1     
Resource group 2
Resource group 3 
Run Code Online (Sandbox Code Playgroud)

如何调整代码以获得如下所示的输出?

Subscription 1,Resource group 1     
Subscription 1,Resource group 2
Subscription 2,Resource group 3 
Run Code Online (Sandbox Code Playgroud)

非常感谢。

powershell azure

2
推荐指数
2
解决办法
3318
查看次数