日期:2014-05-18 浏览次数:20502 次
DECLARE @Xml xml set @Xml=N'<Chapter><CSN_SendTime>2012/3/10 11:54:40</CSN_SendTime></Chapter>' SELECT X.C.value('CSN_SendTime[1]','datetime') AS CSN_SendTime FROM @Xml.nodes('Chapter') AS X(C)
DECLARE @Xml xml set @Xml=N'<Chapter><CSN_SendTime>2012/3/10 11:54:40</CSN_SendTime></Chapter>' SELECT X.C.value('CSN_SendTime[1]','varchar(100)') AS CSN_SendTime FROM @Xml.nodes('Chapter') AS X(C)
------解决方案--------------------
DECLARE @Xml xml set @Xml=N'<Chapter><CSN_SendTime>2012/3/10 11:54:40</CSN_SendTime></Chapter>' SELECT X.C.value('CSN_SendTime[1]','datetime') AS CSN_SendTime FROM @Xml.nodes('Chapter') AS X(C)
------解决方案--------------------
注意2012/3/10 11:54:40长度,,把它放在一行就没有问题了
------解决方案--------------------
DECLARE @Xml xml set @Xml=N'<Chapter><CSN_SendTime>2012/3/10 11:54:40</CSN_SendTime></Chapter>' SELECT X.C.value('CSN_SendTime[1]','nvarchar(20)') AS CSN_SendTime FROM @Xml.nodes('/Chapter') AS X(C) CSN_SendTime -------------------- 2012/3/10 11:54:40 (1 row(s) affected)
------解决方案--------------------
{0}里面的回车符号去掉
------解决方案--------------------
select cast( replace(replace('2012/3/10 11:54:40',char(13),''),CHAR(10),'') as datetime)
------解决方案--------------------
DECLARE @Xml xml set @Xml=N'<Chapter> <CSN_SendTime>2012/3/10 11:54:40</CSN_SendTime></Chapter>' SELECT X.C.value('CSN_SendTime[1]','datetime') AS CSN_SendTime FROM @Xml.nodes('Chapter') AS X(C)
------解决方案--------------------
select cast( replace(replace('2012/3/10
11:54:40',char(13),''),CHAR(10),'') as datetime)