sql-server - 如何在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)
提前致谢!!
解决方案
推荐阅读
- node.js - 无法将集合用户作为 JSON 对象 (getuser())
- arrays - 通过引用特定对象的一个键来获取数组的对象
- architecture - 使用微服务重置依赖于令牌的 API
- database - 在 Clickhouse Docker 容器中访问用户文件 users.xml?
- javascript - Calculate total price with products, size, and quantity in javascript
- javascript - 具有公共和私有方法的 jQuery 插件模板
- javascript - 为什么动态创建的元素的事件不能捕获一次以上?
- php - 如何配置 Nginx 以将特定请求模式路由到托管 Symfony 应用程序的特定 php-fpm 上游?
- javascript - 未定义不是对象(评估“_this.props.navigation”)
- java - Selenium Java - 如何从单个下拉列表中提取数据(时间字段)