Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sql 2000 openxml xsi:nil

Author  Topic 

sbowe
Starting Member

1 Post

Posted - 2006-01-04 : 17:20:46
This is a very simplified example but it should get the point across. I am attempting to pass in a piece of xml with a node that is null. When I serialize the object (.net 2.0) the xml comes out in the following format. If you run the query below you will see that the value of SomethingId is set to 0 when I would expect it to be null. Is there anyway to have the value set to null?

declare @Xml nvarchar(4000), @iDoc int

set @Xml = '<?xml version="1.0"?><Something xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SomethingId xsi:nil="true" /></Something>'

exec sp_xml_preparedocument @iDoc OUTPUT, @Xml

select
SomethingId
from openxml (@iDoc,'/Something')
with
(
SomethingId int 'SomethingId'
)
exec sp_xml_removedocument @iDoc
   

- Advertisement -