| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> mssql >> SQL Server 2005 FOR XML qian tao cha xun shi yong xiang jie
 

SQL Server 2005 FOR XML qian tao cha xun shi yong xiang jie

2008-07-18 06:17:32 编辑來源:互联网 评论
 
本文为【SQL Server 2005 FOR XML嵌套查询使用详解】的拼音翻译版
  xiang bi SQL Server 2000 ti gong de FOR XML cha xun ,SQL Server 2005 ban ben dui xian you gong neng zeng qiang de ji chu shang zeng jia le bu shao xin gong neng , zui wei xi yin ren de gong neng bao kuo dui Xml shu ju lei xing zhi chi 、 shi yong PATH mo shi yi ji qian tao FOR XML cha xun zhi chi deng , zhe yi wei zhe tong guo xin de FOR XML cha xun gong neng ke yi gou zao chu jie gou geng jia ling huo de Xml shu ju 。
  zai SQL Server 2000 zhong FOR XML cha xun de jie guo shi zhi jie yi wen ben fang shi fan hui dao ke hu duan , wei zhi chi SQL Server 2005 zhong de Xml shu ju lei xing ,FOR XML cha xun ti gong le TYPE zhi ling , tong guo TYPE zhi chi fan hui jie guo jiang hui bian wei Xml shu ju lei xing 。 jie xia lai yi SQL Server2005 zhong de AdventureWorks shi li shu ju ku wei li yan lian qi gong neng 。
  xian lai kan di yi ge SQL cha xun :
  DECLARE @TestStringValue nvarchar(1024);
  SET @TestStringValue = (SELECT ProductID,[Name] FROM Production.Product
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO);
  SELECT @TestStringValue;
  shu chu jie guo :
  jie guo wei zi fu chuan , zhi shi nei rong ge shi fu he Xml pian duan yao qiu , bu guo wu fa zai SQL Server Management Studio zhong dian ji yi Xml fang shi xian shi 。
  xia mian dui SQL jin xing xiu gai , zeng jia TYPE zhi ling :
  DECLARE @TestStringValue nvarchar(1024);
  SET @TestStringValue = (SELECT ProductID,[Name] FROM Production.Product
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO,TYPE);
  bu chu yi wai , cha xun jie guo shou dao ru xia cuo wu ti shi :
  bu yuan xu cong shu ju lei xing xml dao nvarchar de yin shi zhuan huan 。 qing shi yong CONVERT han shu lai yun xing ci cha xun 。
  ke jian tong guo TYPE zhi ling fan hui de shu ju yi jing zhuan bian cheng Xml lei xing , gai jin hou de cha xun yu ju ru xia :
  DECLARE @XmlTestValue xml;
  SET @XmlTestValue = (SELECT ProductID,[Name] FROM Production.Product
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO,TYPE);
  SELECT @XmlTestValue;
  tong guo SELECT fan hui de jie guo zhi chi Xml fang shi xian shi 。
  le jie le TYPE zhi ling de gong neng hou , jiu ke yi lai kan FOR XML cha xun dai gei kai fa zhe de geng duo jing xi 。 yi shi li shu ju ku de chan pin biao (Production.Product) he chan pin fen lei zi lei biao (Production.ProductSubcategory) wei li jin xing yan shi 。
  bian xie chan pin zi lei bie wei “9” de chan pin shu ju cha xun :
  SELECT ProductSubcategoryID,[Name] ,
  (SELECT ProductID,[Name] FROM Production.Product Product
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO,TYPE) AS Products
  FROM Production.ProductSubcategory AS Category
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO;
  shu chu jie guo ru xia :
  
  ru guo zai chan pin cha xun zi ju zhong bu ti gong TYPE zhi ling , na me shu chu jiu hui bian cheng xia mian jie guo :
  " />
  yi shang ji ge cha xun jie guo dou mei you dai ming ming kong jian , bu guo SQL Server 2005 tong guo WITH XMLNAMESPACES zi ju ti gong le dui ming ming kong jian de zhi chi , xia mian de cha xun jiang xian shi yi ge wan zheng de dai mo ren ming ming kong jian de Xml wen dang 。
  WITH XMLNAMESPACES ('uri0' as ns0)
  SELECT ProductSubcategoryID,[Name] ,
  (SELECT ProductID,[Name] FROM Production.Product Product
  WHERE ProductSubcategoryID = 9
  FOR XML RAW('ns0:Product'),TYPE) AS 'ns0:Products'
  FROM Production.ProductSubcategory AS Category
  WHERE ProductSubcategoryID = 9
  FOR XML RAW('ns0:Category'),ROOT('ns0:Message');
  shu chu jie guo :
  
  
  ru guo cai yong mo ren ming ming kong jian , bian xie SQL ru xia :
  WITH XMLNAMESPACES (DEFAULT 'http://blog.csdn.net/zhzuo')
  SELECT ProductSubcategoryID,[Name] ,
  (SELECT ProductID,[Name] FROM Production.Product Product
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO,TYPE) AS Products
  FROM Production.ProductSubcategory AS Category
  WHERE ProductSubcategoryID = 9
  FOR XML AUTO,ROOT('Message');
  shu chu jie guo :
  
  
  ling wai , zai SQL Server 2005 zhong zeng jia le FOR XML PATH mo shi , tong guo shi yong FOR XML PATH mo shi ke yi jian li qing xi ling huo de Xml ge shi , xiang bi shi yong FOR XML EXPLICIT geng wei jian dan :
  WITH XMLNAMESPACES (DEFAULT 'http://blog.csdn.net/zhzuo')
  SELECT ProductID AS 'Product/@ProductID',
  Name AS 'Product/Name'
  FROM Production.Product
  WHERE ProductSubcategoryID = 9
  FOR XML PATH(''),ROOT('Products');
  shu chu jie guo :
  Rear Derailleur
  Front Derailleur
  
  zai shi ji ying yong guo cheng zhong , yi .NET ping tai ying yong kai fa wei li , tong guo ADO.NET fang wen SQL Server 2005 fan hui de Xml shu ju jie gou ke yi geng jia feng fu , shen zhi ke yi zuo dao bu zuo Xml yang shi zhuan huan zhi jie fu wu yu shang yi ceng mo kuai 。 zai qi ye ying yong ji cheng fang mian , yi BizTalk ping tai wei li , zai tiao yong SQL Adapter de shi hou ke yi geng jia ling huo , jiang di wei le zhi ding he li Xml Schema dai lai de fu duo xing 。 mu qian , zui xin ban ben de BizTalk(2006 R2) dui shi yong le SQL Server 2005 jia qiang FOR XML gong neng de cun chu guo cheng huo SQL yu ju bu zhi chi tong guo SQL shi pei qi xiang dao sheng cheng XML Schema, bu guo zhe ge wen ti ke yi zhi jie tong guo Visual Studio IDE bian xie fu he shi ji ge shi de XML Schema lai jie jue 。【原文】【汉音对照
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
xiang bi SQL Server 2000 ti gong de FOR XML cha xun ,SQL Server 2005 ban ben dui xian you gong neng zeng qiang de ji chu shang zeng jia le bu shao xin gong neng , zui wei xi yin ren de gong neng bao kuo dui Xml shu ju lei xing zhi chi 、 shi yong PATH mo shi yi ji qian tao FOR XML cha xun zhi chi deng , zhe yi wei zhe tong guo xin de FOR XML cha xun gong neng ke yi gou zao chu jie gou geng jia ling huo de Xml shu ju 。 zai SQL Server 2000 zhong FOR XML cha xun de jie guo shi zhi jie yi wen ben fang shi fan hui dao ke hu duan , wei zhi chi SQL Server 2005 zhong de Xml shu ju lei xing ,FOR XML cha xun ti gong le TYPE zhi ling , tong guo TYPE zhi chi fan hui jie guo jiang hui bian wei Xml shu ju lei xing 。 jie xia lai yi SQL Server2005 zhong de AdventureWorks shi li shu ju ku wei li yan lian qi gong neng 。 xian lai kan di yi ge SQL cha xun : DECLARE @TestStringValue nvarchar(1024); SET @TestStringValue = (SELECT ProductID,[Name] FROM Production.Product WHERE ProductSubcategoryID = 9 FOR XML AUTO); SELECT @TestStringValue; shu chu jie guo : jie guo wei zi fu chuan , zhi shi nei rong ge shi fu he Xml pian duan yao qiu , bu guo wu fa zai SQL Server Management Studio zhong dian ji yi Xml fang shi xian shi 。 xia mian dui SQL jin xing xiu gai , zeng jia TYPE zhi ling : DECLARE @TestStringValue nvarchar(1024); SET @TestStringValue = (SELECT ProductID,[Name] FROM Production.Product WHERE ProductSubcategoryID = 9 FOR XML AUTO,TYPE); bu chu yi wai , cha xun jie guo shou dao ru xia cuo wu ti shi : bu yuan xu cong shu ju lei xing xml dao nvarchar de yin shi zhuan huan 。 qing shi yong CONVERT han shu lai yun xing ci cha xun 。 ke jian tong guo TYPE zhi ling fan hui de shu ju yi jing zhuan bian cheng Xml lei xing , gai jin hou de cha xun yu ju ru xia : DECLARE @XmlTestValue xml; SET @XmlTestValue = (SELECT ProductID,[Name] FROM Production.Product WHERE ProductSubcategoryID = 9 FOR XML AUTO,TYPE); SELECT @XmlTestValue; tong guo SELECT fan hui de jie guo zhi chi Xml fang shi xian shi 。 le jie le TYPE zhi ling de gong neng hou , jiu ke yi lai kan FOR XML cha xun dai gei kai fa zhe de geng duo jing xi 。 yi shi li shu ju ku de chan pin biao (Production.Product) he chan pin fen lei zi lei biao (Production.ProductSubcategory) wei li jin xing yan shi 。 bian xie chan pin zi lei bie wei “9” de chan pin shu ju cha xun : SELECT ProductSubcategoryID,[Name] , (SELECT ProductID,[Name] FROM Production.Product Product WHERE ProductSubcategoryID = 9 FOR XML AUTO,TYPE) AS Products FROM Production.ProductSubcategory AS Category WHERE ProductSubcategoryID = 9 FOR XML AUTO; shu chu jie guo ru xia : ru guo zai chan pin cha xun zi ju zhong bu ti gong TYPE zhi ling , na me shu chu jiu hui bian cheng xia mian jie guo : " /> yi shang ji ge cha xun jie guo dou mei you dai ming ming kong jian , bu guo SQL Server 2005 tong guo WITH XMLNAMESPACES zi ju ti gong le dui ming ming kong jian de zhi chi , xia mian de cha xun jiang xian shi yi ge wan zheng de dai mo ren ming ming kong jian de Xml wen dang 。 WITH XMLNAMESPACES ('uri0' as ns0) SELECT ProductSubcategoryID,[Name] , (SELECT ProductID,[Name] FROM Production.Product Product WHERE ProductSubcategoryID = 9 FOR XML RAW('ns0:Product'),TYPE) AS 'ns0:Products' FROM Production.ProductSubcategory AS Category WHERE ProductSubcategoryID = 9 FOR XML RAW('ns0:Category'),ROOT('ns0:Message'); shu chu jie guo : ru guo cai yong mo ren ming ming kong jian , bian xie SQL ru xia : WITH XMLNAMESPACES (DEFAULT 'http://blog.csdn.net/zhzuo') SELECT ProductSubcategoryID,[Name] , (SELECT ProductID,[Name] FROM Production.Product Product WHERE ProductSubcategoryID = 9 FOR XML AUTO,TYPE) AS Products FROM Production.ProductSubcategory AS Category WHERE ProductSubcategoryID = 9 FOR XML AUTO,ROOT('Message'); shu chu jie guo : ling wai , zai SQL Server 2005 zhong zeng jia le FOR XML PATH mo shi , tong guo shi yong FOR XML PATH mo shi ke yi jian li qing xi ling huo de Xml ge shi , xiang bi shi yong FOR XML EXPLICIT geng wei jian dan : WITH XMLNAMESPACES (DEFAULT 'http://blog.csdn.net/zhzuo') SELECT ProductID AS [url=mailto:]'Product/@ProductID'[/url], Name AS 'Product/Name' FROM Production.Product WHERE ProductSubcategoryID = 9 FOR XML PATH(''),ROOT('Products'); shu chu jie guo : Rear Derailleur Front Derailleur zai shi ji ying yong guo cheng zhong , yi .NET ping tai ying yong kai fa wei li , tong guo ADO.NET fang wen SQL Server 2005 fan hui de Xml shu ju jie gou ke yi geng jia feng fu , shen zhi ke yi zuo dao bu zuo Xml yang shi zhuan huan zhi jie fu wu yu shang yi ceng mo kuai 。 zai qi ye ying yong ji cheng fang mian , yi BizTalk ping tai wei li , zai tiao yong SQL Adapter de shi hou ke yi geng jia ling huo , jiang di wei le zhi ding he li Xml Schema dai lai de fu duo xing 。 mu qian , zui xin ban ben de BizTalk(2006 R2) dui shi yong le SQL Server 2005 jia qiang FOR XML gong neng de cun chu guo cheng huo SQL yu ju bu zhi chi tong guo SQL shi pei qi xiang dao sheng cheng XML Schema, bu guo zhe ge wen ti ke yi zhi jie tong guo Visual Studio IDE bian xie fu he shi ji ge shi de XML Schema lai jie jue 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
越来越漂亮的楚楚(7)
越来越漂亮的楚楚(6)
越来越漂亮的楚楚(5)
越来越漂亮的楚楚(4)
共长一色
水中莲
峰林晚照
远离喧嚣——山村小景
 
>>返回首页<<
 为你推荐
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
©2005- 王朝网络 版权所有