Wednesday

tsql select from xml with xmlns

tsql select from xml with xmlns here is how to do that :
       
declare @document xml ='<TypedPollingResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedPolling/ModifiedProductsGet"><TypedPollingResultSet0><id>2</id><ProductID>M10570</ProductID><OriginalCatalog> Master Recipes HE</OriginalCatalog><Status>0</Status><DateTimeCreated>2014-10-20T11:48:10.373Z</DateTimeCreated></TypedPollingResultSet0><TypedPollingResultSet0><id>1</id><ProductID>M9519</ProductID><OriginalCatalog> Master Recipes HE</OriginalCatalog><Status>0</Status><DateTimeCreated>2014-10-20T11:48:10.373Z</DateTimeCreated></TypedPollingResultSet0></TypedPollingResultSet0>'
;WITH XMLNAMESPACES(DEFAULT 'http://schemas.microsoft.com/Sql/2008/05/TypedPolling/ModifiedProductsGet')
Select T.N.value('id[1]', 'int') as id
from @document.nodes('/TypedPollingResultSet0/TypedPollingResultSet0') as T(N)

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...