首页 > 解决方案 > 如何在powershell中处理$内部参数

问题描述

如何处理用于 SQL 代码的参数中的 $ 符号。如果我要使用带有 Null 的所有 My $Some_text(带 $ 的前缀)的代码(注意只是一个空格)

使用的 POSH 命令:

    $attachSQLCMD1 = @" .........  ....
...................................................
OR (OBJECT_ID(''dbo.User Personalization'',''U'') IS NOT NULL AND EXISTS(SELECT 1 FROM sys.all_objects (NOLOCK) WHERE type=''U'' AND (name like ''%**$**G[_]L Entry'' OR name LIKE ''%**$**Item Ledger Entry'')))
.................................................
..........................................................

$partitions = Get-WmiObject -computername $serverName -query "SELECT * FROM Win32_DiskPartition"
foreach ($partition in $partitions)
{
[string] $diskpart = "{0}_{1};{2}" -f $partition.DiskIndex,$partition.Index,$partition.StartingOffset
Write-Output $diskpart
 "@





 Invoke-Sqlcmd $attachSQLCMD1 -QueryTimeout 0 -ServerInstance $SQLServer -maxcharlength ([int]::MaxValue) 

提前致谢!!

标签: sql-serverpowershellstored-procedures

解决方案


推荐阅读