Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Monday, March 26, 2012

Getting Strange Results using SQLXML and Schema

Hi there,
I've been using the nillable="true" technique to get NULLs returned as
empty elements from the database. In most cases it seems to work just
fine (though I've had the "Parent tag ID 'n' is not among the open
tags" a few times I've been able to resolve it) however in the case of
a table that mostly allows NULLs for all rows (or at least the ones I'm
interested in in the schema) that looks like:
<xsd:complexType name="ADDRESS_TYPE" >
<xsd:sequence>
<xsd:element name="AddressLine1" sql:field="AddressLine"
type="xsd:string" minOccurs="1" nillable="true" />
<xsd:element name="AddressLine2" sql:field="AddressLine2"
type="xsd:string" minOccurs="1" nillable="true" />
<xsd:element name="TownCity" default="" sql:field="TownCity"
type="xsd:string" minOccurs="1" nillable="true" />
(...)
</xsd:sequence>
<xsd:attribute name="id" sql:field="guid" />
</xsd:complexType>
I get results that look something like
<y0:Address id="598E61F5-43B6-45E6-983C-031AF6DB7607"/>
<y0:Address id="718E1BBD-5F41-44C4-B795-0B7F3F32B759"/>
<y0:Address id="8D003B08-39B8-4F3E-BCAF-0D069C936942"/>
<y0:AddressLine1>Test Lane</y0:AddressLine1>
<y0:AddressLine1 xsi:nil="true"/>
<y0:AddressLine1>Potter's Way</y0:AddressLine1>
<y0:AddressLine2/>
<y0:AddressLine2 xsi:nil="true"/>
<y0:AddressLine2>Pumpherston</y0:AddressLine2>
....
I saw the article on SQLXML (http://sqlxml.org/faqs.aspx?faq=28)
relating to this but as I'm not creating the XML Explicit queries
myself rather I'm using Schema I was wondering if anyone had any ideas
how to try and address this and pitfalls to avoid?
Thanks,
Gary
This usually means you havent fully specified the key fields for your tables.
You should specify the key-fields annotation for every table in the mapping
schema. If you dont, your results can be non-deterministic and have issues
similar to the ones you are seeing.
http://msdn.microsoft.com/library/de...tions_9rsj.asp
If that doesnt work, post the mapping schema.
"Gary" wrote:

> Hi there,
> I've been using the nillable="true" technique to get NULLs returned as
> empty elements from the database. In most cases it seems to work just
> fine (though I've had the "Parent tag ID 'n' is not among the open
> tags" a few times I've been able to resolve it) however in the case of
> a table that mostly allows NULLs for all rows (or at least the ones I'm
> interested in in the schema) that looks like:
> <xsd:complexType name="ADDRESS_TYPE" >
> <xsd:sequence>
> <xsd:element name="AddressLine1" sql:field="AddressLine"
> type="xsd:string" minOccurs="1" nillable="true" />
> <xsd:element name="AddressLine2" sql:field="AddressLine2"
> type="xsd:string" minOccurs="1" nillable="true" />
> <xsd:element name="TownCity" default="" sql:field="TownCity"
> type="xsd:string" minOccurs="1" nillable="true" />
> (...)
> </xsd:sequence>
> <xsd:attribute name="id" sql:field="guid" />
> </xsd:complexType>
> I get results that look something like
> <y0:Address id="598E61F5-43B6-45E6-983C-031AF6DB7607"/>
> <y0:Address id="718E1BBD-5F41-44C4-B795-0B7F3F32B759"/>
> <y0:Address id="8D003B08-39B8-4F3E-BCAF-0D069C936942"/>
> <y0:AddressLine1>Test Lane</y0:AddressLine1>
> <y0:AddressLine1 xsi:nil="true"/>
> <y0:AddressLine1>Potter's Way</y0:AddressLine1>
> <y0:AddressLine2/>
> <y0:AddressLine2 xsi:nil="true"/>
> <y0:AddressLine2>Pumpherston</y0:AddressLine2>
> ....
> I saw the article on SQLXML (http://sqlxml.org/faqs.aspx?faq=28)
> relating to this but as I'm not creating the XML Explicit queries
> myself rather I'm using Schema I was wondering if anyone had any ideas
> how to try and address this and pitfalls to avoid?
> Thanks,
> Gary
>

Wednesday, March 21, 2012

Getting rid of unwanted characters!

Hello Gurus, I’ve a table that has a column with a text data type. When th
ey
imported the data from a different system some non ASCII character slipped
into the table. What would be the best way to get rid of them?
For example: A man ne£ds ??help. to A man needs help
thanks in advance.Hi
If this is a one off, you may want to try:
UPDATE myStrings
SET str = STUFF(str,PATINDEX('%[^A-Z ]%',str),1 ,'')
WHERE PATINDEX('%[^A-Z ]%',str) > 0
WHILE @.@.ROWCOUNT > 0
BEGIN
UPDATE myStrings
SET str = STUFF(str,PATINDEX('%[^A-Z ]%',str),1 ,'')
WHERE PATINDEX('%[^A-Z ]%',str) > 0
END
John
"KB" wrote:

> Hello Gurus, I’ve a table that has a column with a text data type. When
they
> imported the data from a different system some non ASCII character slipped
> into the table. What would be the best way to get rid of them?
> For example: A man ne£ds ??help. to A man needs help
> thanks in advance.
>|||http://www.aspfaq.com/2445
"KB" <KB@.discussions.microsoft.com> wrote in message
news:F11D992A-CC05-4776-B43A-A3AB8412F291@.microsoft.com...
> Hello Gurus, I’ve a table that has a column with a text data type. When
> they
> imported the data from a different system some non ASCII character slipped
> into the table. What would be the best way to get rid of them?
> For example: A man ne£ds ??help. to A man needs help
> thanks in advance.
>|||Great Help! Thank you gentlemen.
"KB" wrote:

> Hello Gurus, I’ve a table that has a column with a text data type. When
they
> imported the data from a different system some non ASCII character slipped
> into the table. What would be the best way to get rid of them?
> For example: A man ne£ds ??help. to A man needs help
> thanks in advance.
>