我需要做的是: 1,從sql server數據表中查詢一行xml。請參見下面的圖片,行名爲StageDesc
內容的xml文件。如何使用PowerShell顯示sql表中的xml內容?
2,XML文件內容的路徑//sharespace/test1/10.0.1212.0
,我需要得到的,這是形成爲XML文件<releasepath>//sharespace/test1/10.0.1212.0</releasepath>
。
這裏是我的代碼設法得到它:通過
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlQuery = "SELECT Stage.Description as StageDesc,Stage.StageStatusId FROM [Build].[dbo].[WorkflowInstance_View] as Build
join [Build].[dbo].[Stage_View] as Stage on Build.Id=Stage.[WorkflowInstanceId] where Stage.ParentId is null and Stage.StageStatusId <>4 and Stage.StageStatusId <>7 order by Build.Id desc"
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $Connection
$DBResult = $sqlcmd.ExecuteReader()
$DataTable = New-Object system.data.datatable
$DataTable.load($DBResult)
foreach ($StageDesc in $DataTable) {
[XML]$ReturnedXML=$StageDesc.releasepath
}
的代碼,但什麼都不會返回。爲什麼會發生?有人願意幫助我嗎?
謝謝!我會盡快嘗試〜 – pansal