jose 的个人资料SQL Server 2005 blogs日志列表 工具 帮助

日志


9月19日

XML DATATYPE (series 1)

New to SQL Server 2005, is The XML data type, which  lets you store XML documents and fragments in a SQL Server database. An XML fragment is an XML instance that is missing a single top-level element. You can create columns and variables of the XML type and store XML instances in them. Note that the stored representation of XML data type instances cannot exceed 2 GB.

Where can you use the XML data type
a. Table
b. Variable
c. Parameters
d. Return of a function
 
To do: Store XML to a table

a. Create a Table with XML data type
CREATE TABLE ProductDocs (ID INT IDENTITY PRIMARY KEY,
ProductDoc XML NOT NULL)
GO
 
b. Store XML data  Into the table
INSERT INTO ProductDocs VALUES('
<Product>
<ProductID>1</ProductID>
<ProductName>Chai</ProductName>
<SupplierID>1</SupplierID>
<CategoryID>1</CategoryID>
<QuantityPerUnit>10 boxes x 20   bags</QuantityPerUnit>
<UnitPrice>18.0000</UnitPrice>
<UnitsInStock>39</UnitsInStock>
<UnitsOnOrder>0</UnitsOnOrder>
<ReorderLevel>10</ReorderLevel>
<Discontinued>0</Discontinued>
</Product>
')

c. Retrieve XMLdoc
Select product from productdocs

D. create an XML Schema
CREATE XML SCHEMA COLLECTION ProductSchema AS '
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema"
targetNamespace="
http://www.microsoft.com/schemas/adventureworks/
products"
xmlns:prod="
http://www.microsoft.com/schemas/adventureworks/
products">
<xs:element name="Product">
<xs:complexType>
<xs:sequence>
<xs:element ref="prod:ProductID" />
<xs:element ref="prod:ProductName" />
<xs:element ref="prod:SupplierID" />
<xs:element ref="prod:CategoryID" />
<xs:element ref="prod:QuantityPerUnit" />
<xs:element ref="prod:UnitPrice" />
<xs:element ref="prod:UnitsInStock" />
<xs:element ref="prod:UnitsOnOrder" />
<xs:element ref="prod:ReorderLevel" />
<xs:element ref="prod:Discontinued" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ProductID" type="xs:integer" />
<xs:element name="ProductName" type="xs:string" />
<xs:element name="SupplierID" type="xs:integer" />
<xs:element name="CategoryID" type="xs:integer" />
<xs:element name="QuantityPerUnit" type="xs:string" />
<xs:element name="UnitPrice" type="xs:double" />
<xs:element name="UnitsInStock" type="xs:integer" />
<xs:element name="UnitsOnOrder" type="xs:integer" />
<xs:element name="ReorderLevel" type="xs:integer" />
<xs:element name="Discontinued" type="xs:boolean" />
</xs:schema> '
 
E. retrieve Schemas
SELECT * FROM sys.xml_schema_collections
Schemas are stored in Sys.xml_schema_collections

评论 (1)

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

若要添加评论,请使用您的 Windows Live ID 登录(如果您使用过 Hotmail、Messenger 或 Xbox LIVE,您就拥有 Windows Live ID)。登录


还没有 Windows Live ID 吗?请注册

<a href="http://www.rmt-wm.com">RMT-WM</a> <a href="http://rmtvip.jp">rmtvip</a>The baby eagle liked the nest. 「<a href="http://www.rmt-wm.com/games/aion.html">-aion rmt</a>」It was the only world he had ever known. <a href="http://www.rmtvip.jp/game/aion.html">aion RMT</a> It was warm and comfortable, had a great view, 「<a href="http://www.rmt-wm.com/games/0003.html"> リネージュ2 rmt</a> and even better, he had all the food and love and attention that a great mother eagle could provide. <a href="http://www.rmtvip.jp/game/Lineage2_リネージュ2_RMT.html">リネージュ2 RMT</a> Many times each day the mother would swoop down from the sky and land in the nest and feed the baby eagle delicious morsels of food. She was like a god to him, he had no where she came from or how she worked her magic. <a href="http://www.rmt-wm.com/games/A004.html">アラド戦記 rmt</a>The baby eagle was hungry all the time, but the mother eagle would always come just in time with the food and love and attention he craved. The baby eagle grew strong. <a href="http://www.rmtvip.jp/game/アラド戦記_RMT.html">アラド戦記 RMT</a>His vision grew very sharp. He felt good all the time. <a href="http://www.rmt-wm.com/games/0005.html">ff11 rmt</a>Until one day, the mother stopped coming to the nest. <a href="http://www.rmtvip.jp/game/FF11_FFXI_RMT.html">FF11 RMT</a>Thelooked up at the mother and cried "Why did you abandon me? I'm going to die any minute. How could you do faster. He screamed. "I'm dying I'm dying," he cried. He picked up more speed. <a href="http://www.replica-watches-mall.com">Replica Watche</a>
He looked up at his mother. "How could you do this to me?" He looked down. Something strange happens.
9 月 26 日

引用通告

此日志的引用通告 URL 是:
http://joeydjs-sql2k5.spaces.live.com/blog/cns!418E3F917301E76D!165.trak
引用此项的网络日志