SQL 中 sp_xml_preparedocument,openxml的使用
来源:互联网 发布:10月经济数据点评 编辑:程序博客网 时间:2024/05/21 09:22
目的通过解析 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 中 sp_xml_preparedocument,openxml的使用
- sp_xml_preparedocument的使用
- SQL Server2005中使用XML-OPENXML
- SQL Server2005中使用XML-OPENXML
- 关于SqlServer中openxml的使用
- SQL Server 的For XML及sp_xml_preparedocument
- sp_xml_preparedocument OPENXML sp_xml_removedocument截取XML片段或指定格式的数据
- SQL Server2000的OpenXML特性
- 关于SqlServer中openxml的使用 导入XML
- 使用OPENXML(Using OpenXML)
- 使用sp_xml_preparedocument处理XML文档 保存到sqlserver中
- 存储过程使用sp_xml_preparedocument处理XML文档的方法
- sp_xml_preparedocument
- sp_xml_preparedocument
- 使用SQL Server的OpenXML解析带有命名空间的XML片段
- sp_xml_preparedocument sp_xml_removedocument 使用 实例 解析
- 使用sp_xml_preparedocument处理XML文档
- ------OPENXML和MERGE联合使用的方法--------
- PHP设计模式之Singleton模式
- C/C++从入门到高手所有必备PDF书籍
- ubuntu tftp服务配置
- 这些情况使用StringBuilder代替String(抄袭加翻译)
- 核心层(网络的高速交换主干)、汇聚层(提供基于策略的连接)、接入层 (将工作站接入网络)。
- SQL 中 sp_xml_preparedocument,openxml的使用
- PROCEDURE and FUNCTION
- ipv6中配置地址的几种方法
- windows 命令行
- 局域网音频对讲
- 动态代理
- 最简单的Ogre系列之二——画线
- wordpress相册插件
- AXIS客户端调用出错org.apache.axis.NoEndPointException