Is there a way to query the SQL Server XML type so that for an element with xsi:nil="true" , null is returned instead of the default datetime, which is 1900-01-01 00:00:00.000 ?
Here is a snippet of code
declare @data xml set @data = '<DOD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />' select Value1 = @data.value('/DOD[1]', 'datetime'), Value2 = IsNull(@data.value('/DOD[1]', 'datetime'), 'NOT NULL?'), Value3 = nullif(@data.value('/DOD[1]', 'datetime'), '1900-01-01')
Values โโValue1 and Value2 return 1900-01-01 00:00:00.000 . Is there any way to return zero? without using nullif ?
sql xml sql-server tsql sql-server-2005
Sung
source share