TSQL将Xml DateTime(xs:DateTime)转换为SQL DateTime
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TSQL将Xml DateTime(xs:DateTime)转换为SQL DateTime相关的知识,希望对你有一定的参考价值。
This is as small as this can go:'xs:dateTime(sql:variable("@stringDate"))'
It needs to be a literal string for the Value() function.
Xml Datatype
http://msdn2.microsoft.com/en-us/library/ms189887.aspx
Sql:Variable() Function
http://msdn2.microsoft.com/en-us/library/ms188254.aspx
'xs:dateTime( val )'
http://www.w3schools.com/xpath/xpath_functions.asp#datetime
Xml Datatype Methods
http://msdn2.microsoft.com/en-us/library/ms190798.aspx
DECLARE @stringDate VARCHAR(30); DECLARE @myXmlDate xml DECLARE @serializedDate datetime DECLARE @xQuery VARCHAR(100) SET @stringDate = '2007-10-03T11:24:07.003+12:00' SET @myXmlDate = CAST('' AS xml) --Gets an empty Xml datatype SET @serializedDate = @myXmlDate.value('xs:dateTime(sql:variable("@stringDate"))', 'datetime') SELECT @serializedDate
以上是关于TSQL将Xml DateTime(xs:DateTime)转换为SQL DateTime的主要内容,如果未能解决你的问题,请参考以下文章