????? ??????? XML ??? SQL Server ?? ???? ????? ???? XML

?????? ????????? ?????? ?????????
???? ???????: 316005 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ????? ???????? ???? ??? ??????? ?? ?? XML ??? ????? ?????? Microsoft SQL Server 2000 ???????? ???? ????? ???? XML. ???? ??? ??????? ??????? ???? ????? ??? ????? ????? ?????? XML ??? ???? ????? ?????? ?? ????? ????????.

?????? ??? ??? ?????? Microsoft SQL Server 2005 ? ???? ??????? "????? ????? ???? XML" ?? SQL Server 2005 ????????.

???????

???????? ??????? ???????? ?? ??? ??????? ???? ???????:
  • ??? ??????? 1 XML ?? 2000 ???? SQL (SQLXML) ? ?? ????.
????? ??????? ????????:
  • ????? XML.

????? ???? ????? ??????

???? ??????? ??????? ?????? ???? ????? ???????? ???? ????? ???? ????? ???? XML.
  1. ????? ????? ?????? ???? MyDatabase ?? SQL Server.
  2. ??? ???? ??????? SQL ?? ?? ?????? ????? ???????? ??? MyDatabase.
  3. ????? ???? ??????? ?? MyDatabase ?? ???? ????? ????? SQL ??????? ?? "??????? ????":
    USE MyDatabase
    CREATE TABLE Customer (
       CustomerId INT PRIMARY KEY,
       CompanyName NVARCHAR(20),
       City NVARCHAR(20))
    					

????? ??? ???? ?????? XML

??? ?? ???? ?????? ????? ???????? ????????. ??? ??? XML ?? ??????? ?? ?? ???? ????? ?? C:/Customers.xml.
<ROOT>
  <Customers>
    <CustomerId>1111</CustomerId>
    <CompanyName>Sean Chai</CompanyName>
    <City>NY</City>
  </Customers>
  <Customers>
    <CustomerId>1112</CustomerId>
    <CompanyName>Tom Johnston</CompanyName>
    <City>LA</City>
  </Customers>
  <Customers>
    <CustomerId>1113</CustomerId>
    <CompanyName>Institute of Art</CompanyName>
  </Customers>
</ROOT>
				

????? ??? ?????? ?????

??? ????? ?????? ?? ??? ?????? ?????? ????? ???? ?????? XML ??? ????? ???? ??????? ?? ????? ????????. ??? ??? XML ?? ??????? ?? ?? ???? ????? ?? C:/Customermapping.xml.
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data" 
        xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"  
        xmlns:sql="urn:schemas-microsoft-com:xml-sql" > 

   <ElementType name="CustomerId" dt:type="int" />
   <ElementType name="CompanyName" dt:type="string" />
   <ElementType name="City" dt:type="string" />

   <ElementType name="ROOT" sql:is-constant="1">
      <element type="Customers" />
   </ElementType>

   <ElementType name="Customers"  sql:relation="Customer">
      <element type="CustomerId"  sql:field="CustomerId" />
      <element type="CompanyName" sql:field="CompanyName" />
      <element type="City"        sql:field="City" />
   </ElementType>

</Schema>
				

????? VBScript ????? ???? XML ???? ????? ??????

??? ?? ???????? ????? ???? ?????? ???? ????? ???? XML ??? ????? ????? ????? ??? ??????? ?? "????? XML ?????? ???? ???" ??????? ?? ?????? ???? ?? ?????? ?? "????? ???? ??? ???? ????????" ????? ???????? ?????? ????? ??????? ?? ????? "????? ????? ???? ???". ??? ??? ???????? ???????? VBScript ?? ??????? ?? ?? ???? ????? ?? C:\Insertcustomers.vbs.
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=MySQLServer;database=MyDatabase;uid=MyAccount;pwd=MyPassword"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "c:\customermapping.xml", "c:\customers.xml"
Set objBL = Nothing
				
????? ????? ???????? ?????_????_??????? ??? ????? ?????? ?? ????????? ???????? ???? ???? ????? ???????? ????? ?? ????? SQL Server. ??? ?? ????? ????? ?????? ? ???? ????? ????? ??????? ??? ????? ???????? ?????:
??? ?? ??????? ????? ????????

????? VBScript ?? ??????

?? ?????? ?????? VBScript C:\Insertcustomers.vbs ????? ????? ??????? ??????? ?? ???? ???????.

???? ?? ??? ????

??????? ??? ????? ???????? MyDatabase ?? ???? ??????? SQL ? ?? ?? ?????? ??? ?????????:
SELECT * FROM Customer
				
?????? ????? ????? ?? ??????? ?? ????? "????? ??? ???? ?????? XML" ???????? ?? ???? ??????? ????.

????? ?????

???? ????? ???? XML ?????? ???:
  • ????? ????? XML ??? ??????? ??????? ???????? ????? ??????? ?? ??? ???? XML.
  • ????? ?????? ?????? ??? ????? ????? ?????.
  • ????? ?? ??? ????? ?????.
  • ????? ?? ??????? ????? ??? ????? ?????.



?????

SQLXML ????????; ???????: "????? ????? ???? ??????? ?? ?????? XML"

???????

???? ???????: 316005 - ????? ??? ??????: 21/?? ??????/1426 - ??????: 4.4
????? ???
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 64-bit Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Workgroup Edition
????? ??????: 
kbmt kbhowtomaster KB316005 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????316005

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com