目的通过解析 XML 获取
QuestionID,QuestionTypeID,OptionText
SP:
create proc dbo.TestSaveSurvey
(
@XML ntext
)
as
begin
   declare @doc int
   declare @nError int
    set @nError=50001
    --sp_xml_preparedocument要读取的XML文档时@XML,
   exec sp_xml_preparedocument @doc output,@xml
   --通过OpenXML获取行集视图,
   --/UIResponse/SurveyDetails/s/p/q/o 表示我要出来的节点
    select * into #NullOptionTemp from openxml(@doc,'/UIResponse/SurveyDetails/s/p/q/o',1)
              /*
              QuestionID 列名称
              int 数据类型
              ../@QuestionId:Xpath,将那些节点映射到列
              */
              with
              (
               QuestionId int '../@QuestionId',
               QuestionTypeId int '../@QuestionTypeId',
               OptionText nvarchar(100) '@OptionText'
              ) 
              where OptionText is null and QuestionTypeid in(2,3,4,5,6,10)
              if exists(select * from #NullOptionTemp)
              begin
                  set @nError=50003
                  goto error
              end
              delete from #NullOptionTemp
     error:
          exec sp_xml_removedocument @doc
        return @nError
end

Exec TestSaveSurvey '

<?xml-stylesheet type=''text/xsl'' href=''styles/GenericPage.xslt''?>
<UIResponse Page="Survey" Action="Edit">
    <UserInfo>
        <u UserId="1304" UserLoginName="fareast\v-guohu" UserFullName="Guo Hu">
            <r RoleId="1"/>
        </u>
    </UserInfo>
    <SurveyDetails>
        <s SurveyId="2253" SurveyName="The Questions have no options in the survey" SurveyDescription="The Questions have no options in the survey description" CategoryId="0" LanguageId="6" StatusId="11" SurveyFriendlyName="question_have_no_options" SurveyTitle="The Questions have no options in the survey" IntroductionText="" ThankYouText="" GraphicUrl="" GraphicAltText="" RequiredExplanationText="" RequiredErrorText="" PreviousButtonText="" NextButtonText="" CloseButtonText="Close" SkipButtonText="Skip" FinishButtonText="Finish" CancelButtonText="Cancel" XslTemplatePath="" AcceptButtonText="Accept" DeclineButtonText="" OptOutText="" TrackingText="" ExpireTime="0" Updatable="1" Publishable="1" AnalyticsReadable="1" SurveySiteName="GN">
            <p PageId="132" PageName="Page: -1" NextPageId="0">
                <q QuestionId="13111" QuestionName="test question" QuestionTypeId="3" QuestionRequiredFlag="0" QuestionText="Do you like to have this survey?" VariableName="" Randomization="0" NumberOfColumns="0" DontKnowFlag="0">
                    <o OptionId="19948" OptionText="like it!" NonSelect="0" OptionValue="0" VariableName="" PipingVariableName="" Fixed="0" Exclusive="0"/>
                    <o OptionId="19949" OptionText="Don''t like it!" NonSelect="0" OptionValue="1" VariableName="" PipingVariableName="" Fixed="0" Exclusive="0"/>
                </q>
                <q QuestionId="13117" QuestionName="new radio question" QuestionTypeId="3" QuestionRequiredFlag="0" QuestionText="" VariableName="" Randomization="0" NumberOfColumns="0" DontKnowFlag="0">
                    <o OptionValue="0" VariableName="" PipingVariableName="" Fixed="0" Exclusive="0"/>
                </q>
            </p>
        </s>
    </SurveyDetails>
</UIResponse>

'

sql XML处理,sp_xml_preparedocument,openxml相关推荐

  1. sql xml 入门

    /* sql xml 入门:--by jinjazz--http://blog.csdn.net/jinjazz1.xml: 能认识元素.属性和值2.xpath: 寻址语言,类似windows目录的查 ...

  2. xquery删除_XQuery实例删除SQL XML文档

    xquery删除 Delete operations over SQL XML should be possible with either erasing the XML document with ...

  3. java xml sql_走进 SQL/XML

    DBA:XML 走进 SQL/XML 作者:Tim Quinlan 概览 SQL 与 XML 的互操作性,了解如何着手处理存储在数据库中的 XML 文档. 2006 年 12 月发布 XML 数据通常 ...

  4. SQL XML 字段操作

    DECLARE @myDoc xml       SET @myDoc = '<root>           <item ID="1">          ...

  5. Excel 数据导入SQL XML 自动生成表头

    去出差的时候应客户要求要要将Excel 文件内的数据批量导入到数据库中,而且有各种不同种类的表格,如果每一个表格多对应一个数据表的话, 按照正常的方法应该是创建数据表,创建数据库中映射的数据模型,然后 ...

  6. java 读取sql xml文件是否存在_java.oracle問題,如下,我看到一个XML文件有一个SQL。...

    一个XML文档,可以先构造一个DOM,然后将DOM转化为xml序列,输出或者生成文件.package test; import java.io.ByteArrayOutputStream; impor ...

  7. sql xml 带冒号_Jupyter与SQL魔法

    6行代码在Jupyter里搞定PostgreSQL从安装到查询里,其中三行代码用于检查Postgres安装是否成功, %load_ext sql%sql postgresql://postgres:@ ...

  8. sql.xml大于小于号处理的方法

    <if test="startTime != null and startTime != ''">AND i_DataTime <![CDATA[ >= ] ...

  9. mybatis sql xml 字符逃脱

    where a 不等于 1 where a <> 1 where a <![CDATA[<>]]> 1 转载于:https://www.cnblogs.com/zn ...

最新文章

  1. 微信表白墙 微信小程序 吐槽墙 表白墙 java 开发
  2. 2018年对PHP的新认知
  3. 微软Silverlight,你应该知道的10件事
  4. WordPress窗体化侧边栏
  5. 第二次作业+105032014098
  6. Linux命令大全搜索网站模板
  7. thinkcmf5调用指定分类的二级_python机器学习API介绍11: 伯努利贝叶斯分类器
  8. 获取数据库值,再在其值上做修改
  9. 虚拟机安装VMware ESXi 6.7安装过程介绍
  10. Objective-C中的typedef枚举是什么?
  11. 卷积神经网络第四周作业1 - Face Recognition for the Happy House - v1
  12. sqlserver内存释放心得
  13. Eureka源码深度刨析-(5)EurekaServer处理服务发现
  14. 《Using OpenRefine》翻译~10
  15. 【EasyAR学习】平面追踪、表面跟踪和运动跟踪、稀疏空间地图
  16. 把Ethernet(以太网)基本工作原理说清楚
  17. 如何在xshell中导入xsh
  18. 引用参数如何设缺省值(默认值)(C++)
  19. 随机编码生成器MD5加密字符串工具
  20. Java 按照拼音首字母排序

热门文章

  1. 出门问问发布无线智能耳机,李志飞:语音交互的下一个爆点
  2. 最强AlphaGo怎样炼成?刚刚,DeepMind团队进行了全面解读
  3. 单手撸了个springboot+mybatis+druid 1
  4. linux6系统用docker安装jumpserver
  5. (十四)函数参数和返回值
  6. 下个乳业蓝海风口 竟很可能是低温鲜奶?
  7. 每日Ubuntu小技巧——在Ubuntu中使用音乐软件“声破天”Spotify
  8. VMware Linux VDI 安装步骤
  9. Linux 入门笔记
  10. ARP挂马***--嗅探欺骗的最恐怖方式