Добро пожаловать в форум, Guest >> Войти | Регистрация | Поиск | Правила | | В избранное | Подписаться | ||
Все форумы / Microsoft SQL Server |
![]() ![]() |
BKV88 Member Откуда: Москва Сообщений: 243 |
Добрый день! Есть некий пакет который берет данные из xml и заливает их в Ms SQL Server Есть xml файл: <?xml version="1.0" ?> <Data xmlns="HtiXSDSchema"> <Agreement> <AgreementIdentificator>123</AgreementIdentificator> <OperatorIdentificator>321</OperatorIdentificator> <OrganizationIdentificator>44</OrganizationIdentificator> <Properties> <Property Name="OperatorIdent">744</Property> <Property Name="OrganizationIdent">444</Property> <Property Name="FormGroup">OSN</Property> </Properties> </Agreement> </Data> Начал писать для него xsd схему <xsd:element name="Data"> <xsd:complexType> <xsd:sequence> <xsd:element name="Agreement"> <xsd:complexType> <xsd:sequence> <xsd:element name="AgreementIdentificator"> <xsd:simpleType> <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52"> <xsd:maxLength value="60" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="OperatorIdentificator"> <xsd:simpleType> <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52"> <xsd:maxLength value="60" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="OrganizationIdentificator"> <xsd:simpleType> <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52"> <xsd:maxLength value="60" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="Properties"> <xsd:complexType> <xsd:sequence> <xsd:element name="OrganizationIdent" type="sqltypes:varchar"/> А вот как описать не могу догнать <Properties> <Property Name="OperatorIdent">744</Property> <Property Name="OrganizationIdent">444</Property> <Property Name="FormGroup">OSN</Property> </Properties> |
30 июл 14, 13:33 [16376692] Ответить | Цитировать Сообщить модератору |
BKV88 Member Откуда: Москва Сообщений: 243 |
В базу должны попадать значения
Сообщение было отредактировано: 30 июл 14, 13:55 |
|||||||||||||
30 июл 14, 13:49 [16376856] Ответить | Цитировать Сообщить модератору |
ЕвгенийВ Member Откуда: Москва Сообщений: 4962 |
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="HtiXSDSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Data"> <xs:complexType> <xs:sequence> <xs:element name="Agreement"> <xs:complexType> <xs:sequence> <xs:element name="AgreementIdentificator" type="xs:unsignedByte" /> <xs:element name="OperatorIdentificator" type="xs:unsignedShort" /> <xs:element name="OrganizationIdentificator" type="xs:unsignedByte" /> <xs:element name="Properties"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Property"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="Name" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> |
30 июл 14, 14:21 [16377122] Ответить | Цитировать Сообщить модератору |
BKV88 Member Откуда: Москва Сообщений: 243 |
Как-то криво данные попадают в таблицу К сообщению приложен файл. Размер - 15Kb |
30 июл 14, 14:38 [16377228] Ответить | Цитировать Сообщить модератору |
BKV88 Member Откуда: Москва Сообщений: 243 |
К сообщению приложен файл. Размер - 61Kb |
30 июл 14, 14:39 [16377230] Ответить | Цитировать Сообщить модератору |
BKV88 Member Откуда: Москва Сообщений: 243 |
План запроса К сообщению приложен файл. Размер - 18Kb |
30 июл 14, 14:39 [16377235] Ответить | Цитировать Сообщить модератору |
BKV88 Member Откуда: Москва Сообщений: 243 |
Кто нибудь поможет каким образом можно реализовать или структуировать данные? |
30 июл 14, 20:55 [16379228] Ответить | Цитировать Сообщить модератору |
LexusR Member Откуда: Novosibirsk Сообщений: 1887 |
declare @xml xml set @xml = '<Data xmlns="HtiXSDSchema"> <Agreement> <AgreementIdentificator>123</AgreementIdentificator> <OperatorIdentificator>321</OperatorIdentificator> <OrganizationIdentificator>44</OrganizationIdentificator> <Properties> <Property Name="OperatorIdent">744</Property> <Property Name="OrganizationIdent">444</Property> <Property Name="FormGroup">OSN</Property> </Properties> </Agreement> <Agreement> <AgreementIdentificator>234</AgreementIdentificator> <OperatorIdentificator>567</OperatorIdentificator> <OrganizationIdentificator>77</OrganizationIdentificator> <Properties> <Property Name="OperatorIdent">999</Property> <Property Name="OrganizationIdent">222</Property> <Property Name="FormGroup">ttt</Property> </Properties> </Agreement> </Data>' if OBJECT_ID('tempdb..#Buffer') is not null drop table #Buffer select c.value('(../*:AgreementIdentificator)[1]','varchar(100)') as AgreementIdentificator ,c.value('(../*:OperatorIdentificator)[1]','varchar(100)') as OperatorIdentificator ,c.value('(../*:OrganizationIdentificator)[1]','varchar(100)') as OrganizationIdentificator ,c.value('(./*:Property[@Name="OperatorIdent"]/text())[1]','varchar(100)') as OperatorIdent ,c.value('(./*:Property[@Name="OrganizationIdent"]/text())[1]','varchar(100)') as OrganizationIdent ,c.value('(./*:Property[@Name="FormGroup"]/text())[1]','varchar(100)') as FormGroup into #Buffer from @xml.nodes('//*:Properties') t(c) select * from #Buffer |
31 июл 14, 07:33 [16379904] Ответить | Цитировать Сообщить модератору |
Все форумы / Microsoft SQL Server | ![]() |