SQL-Server - Generate an XML document

Results 1 to 2 of 2

Thread: SQL-Server - Generate an XML document

  1. #1
    Join Date
    Dec 1969

    Default SQL-Server - Generate an XML document

    Im trying to update a row that all collumns are required (can not be null). Let say if i want to remove "No2" and do the update but by default i want to make sure that in my collumn "No2" i have zero into it.<BR><BR>=================<BR>with tbl_xmltest<BR>=================<BR>My problem is on this line above. When i remove in my XML column No2 i got an error.. "&#039;OpenXML&#039;. This column cannot be NUL". Is there a way to use my sql-command <BR><BR>================================<BR>declar e @data nvarchar(4000)<BR>declare @handle int<BR><BR>--select top 1 * from tbl_xmltest for xml auto<BR>set @data = &#039;&#060;tbl_x005F_xmltest No1="1111" No2="234" No3="3333"/&#062;&#039;<BR><BR><BR>exec sp_xml_preparedocument @handle output, @data<BR><BR>begin tran<BR>select * from tbl_xmltest<BR><BR>insert into tbl_xmltest select * from openxml(@handle, &#039;//tbl_x005F_xmltest&#039;) with tbl_xmltest<BR> <BR>select * from tbl_xmltest<BR>rollback<BR>EXEC sp_xml_removedocument @handle

  2. #2
    Join Date
    Dec 1969

    Default this may help


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts