Arrays 选择位于另一个阵列Powershell中的阵列的列/属性
原始表格/集合($clctionTbl)Arrays 选择位于另一个阵列Powershell中的阵列的列/属性,arrays,sql-server,powershell,multidimensional-array,collections,Arrays,Sql Server,Powershell,Multidimensional Array,Collections,原始表格/集合($clctionTbl) Col3数组/集合仍然具有其他属性,例如 Status Id Active A1 Retired A2 我想通过Powershell的Data.SQLClient.SqlBulkCopy 可乐 可乐 仅Col3的Id列 我曾尝试直接将行添加到数据表中,但不是将数据Col3作为类型返回,该类型是System.Collections.Generic.List 我知道我可以手动键入每个属性,就像 $Col1Val = $clctionTbl.Col
Col3
数组/集合仍然具有其他属性,例如
Status Id
Active A1
Retired A2
我想通过Powershell的Data.SQLClient.SqlBulkCopy
可乐
可乐
仅Col3的Id列
我曾尝试直接将行添加到数据表中,但不是将数据Col3
作为类型返回,该类型是System.Collections.Generic.List
我知道我可以手动键入每个属性,就像
$Col1Val = $clctionTbl.Col1
$Col2Val = $clctionTbl.Col2
$Col3Val = $clctionTbl.Col3.Id
并手动插入(foreach)或将它们添加到数据表中,然后将其批量插入到SQL表中,但
关于如何以更好的方式获得期望的输出,有什么想法吗?我有点希望powershell中有一个子选择来获取内部数组/集合的列
要插入SQL表中的所需输出
Col1 Col2 "Col3's Id column"
1 test1 A1,A2
2 test2 B
3 test3 C1,C2,C3
4 test4 ....
$clctionTbl |选择Col1,Col2,@{Name=“Col3ID”;Expression={$\.Col3-join','}
谢谢你!!这确实有效。我不知道我能那样参加。对Expression={$\u.Col3.Id-join','}
@A_horse_,with_no_name,im使用MS SQL server EE,Col3将是我的SQL表中的varchar(200)。
Col1 Col2 "Col3's Id column"
1 test1 A1,A2
2 test2 B
3 test3 C1,C2,C3
4 test4 ....