我正在开发一个具有 JSON 格式输出的项目。我需要清楚地了解 JSON 数组结构。所以有些字段像数组一样是多个条目的。如果一个元素是一个数组但只有一个值,那么它的结构中是否仍然包含数组节点“[”?
例子:
这是一个示例 JSON 元素,它是一个数组并具有多个值。
"Talents": [
{
"Items": "test"
},
{
"Items": "test"
}
]
Run Code Online (Sandbox Code Playgroud)
如果这个元素没有多个值,会不会出现如下的情况?
"Talents":
{
"Items": "test"
}
Run Code Online (Sandbox Code Playgroud)
对于具有单个值的数组类型元素,不会出现“[”。有人可以澄清一下吗?
我正在从事一个由另一个人拥有的项目。他创建了一个作业来更新 SQL Server 中少数表中的一堆字段。该工作基于 SSIS 包。现在我有了 DTSX 文件和禁用的作业。当我在更改 DTSX 文件中的旧凭据后尝试启用该作业时,出现了奇怪的错误。我想查看 SSIS 包背后的代码,并想了解更新过程是如何编码的。有没有办法做到这一点?
我有两个非常简单的表加入但我错过了某个地方,我没有得到所需的输出:
表格1:
表#2:
期望的输出:
查询:
create table #temp1
(
client_id int,
identifier int,
pp_id int,
ch_id int,
code varchar(20),
program varchar(20),
startdate date,
enddate date,
ssc varchar(50)
)
insert into #temp1
values (9908,789654123,1567,1566,'OP','xASMT','1/1/2019','1/4/2019','A201901044F010134NNN01D 151 143 093 ')
create table #temp2
(
client_id int,
identifier int,
pp_id int,
ch_id int,
code varchar(20),
program varchar(20),
startdate date,
enddate date,
ssc varchar(20)
)
insert into #temp2
values(9908,789654123,1574,1573,'OP','SU1','1/1/2019','1/4/2019',NULL)
--My query:
select
t1.client_id, t1.identifier,
concat(t1.code, t1.startdate, t1.enddate, t1.ssc),
concat(t2.code, t2.startdate, t2.enddate, t2.ssc)
from
#temp1 t1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据大小写更新表中的 XML 数据列。下面是我的代码:
UPDATE #temp
SET xml_data = CASE
WHEN @type = 'G'
THEN xml_data.modify('insert <type>G</type> after (/Main/name)[1]');
WHEN @type = 'Q'
THEN xml_data.modify('insert <type>Q</type> after (/Main/name)[1]');
END
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
XML 数据类型方法“修改”的错误使用。在这种情况下,需要一个非突变方法。
期望的输出:
@type = 'Q',插入类型节点为Q@type = 'G',插入类型节点为GXML结构:
<Main>
<name>John doe</name>
<type>Q</type>
<age>15</age>
</Main>
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?!
更新:
我编辑的查询:
UPDATE #temp
SET xml_data.modify('insert <Type>{sql:variable("@var")}</Type> after (/Main/name)[1]')
Run Code Online (Sandbox Code Playgroud)
此查询将类型添加到 XML 的末尾。输出:
<Main>
<name>John doe</name>
<age>15</age>
</Main>
<Type>Q</Type>
Run Code Online (Sandbox Code Playgroud) 我正在使用PowerShell脚本从TFS服务器下载项目和集合的列表。下面是我的脚本:
$uri = "http://xxxserver/tfs"
$tfsConfigurationServer = [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]::GetConfigurationServer($uri)
$tpcService = $tfsConfigurationServer.GetService("Microsoft.TeamFoundation.Framework.Client.ITeamProjectCollectionService")
$sortedCollections = $tpcService.GetCollections() | Sort-Object -Property Name
$numberOfProjects = 0
foreach($collection in $sortedCollections) {
$collectionUri = $uri + "/" + $collection.Name
$tfsTeamProject = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($collectionUri)
$cssService = $tfsTeamProject.GetService("Microsoft.TeamFoundation.Server.ICommonStructureService3")
$sortedProjects = $cssService.ListProjects() | Sort-Object -Property Name
Write-Host $collection.Name "- contains" $sortedProjects.Count "project(s)
Run Code Online (Sandbox Code Playgroud)
执行此脚本后,我出现以下错误:
Unable to find type [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]: make sure that the assembly
containing this type is loaded.
At $\getProjList.ps1:2 char:1
+ $tfsConfigurationServer = [Microsoft.TeamFoundation.Client.TfsConfigurationServe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: …Run Code Online (Sandbox Code Playgroud) 我有一个存储位列的临时表.我想对这些列进行空检查,并使它们为'Null'.
我的代码是
isnull(a.isrecordable, 'null')
Run Code Online (Sandbox Code Playgroud)
这是一个错误
将varchar值'null'转换为数据类型位时转换失败
所以这个过程是,从我存储此列的临时表中bit,我想isnull检查并拉出XML格式输出,它将通过.Net工具转换为JSON.在JSON中,我希望列在没有值时显示"null",因为我不想让列远离JSON报告.
更新:
更新了我的小查询.CID不能位,所以替换列:)
有什么帮助?!
我有一个包含' - '或''的示例文本.所以我想要一个sql replace语句来替换' - '和'''''.
我的查询是:
SELECT REPLACE('SQL-Tu torial','-',' ','');
Run Code Online (Sandbox Code Playgroud)
期望的结果:
SQLTutorial
Run Code Online (Sandbox Code Playgroud)
错误:我收到Replace函数参数的错误.
替换函数需要3个参数.
有帮助吗?
我有以下查询:
select STUFF((SELECT ',' + rr1._cv_id
FROM #reportrows rr1
WHERE rr1._c_id=rr._c_id
FOR XML PATH('')),1, 1,null)FROM #reportrows rr
Run Code Online (Sandbox Code Playgroud)
在此查询中,_cv_id 是整数类型。运行此查询后,我看到以下错误:
Conversion failed when converting the varchar value ',' to data type int.
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?
sql ×6
sql-server ×6
xml ×2
arrays ×1
etl ×1
javascript ×1
json ×1
powershell ×1
ssis ×1
ssis-2012 ×1
t-sql ×1
tfs ×1