Showing posts with label problemi. Show all posts
Showing posts with label problemi. Show all posts

Wednesday, March 28, 2012

problems in Like

hi there,
im facing a wierdo problem

i had data in a foxpro database, i import it to a sqlserver 2000 database with collation Arabic_CI_AS , cause the data is arabic and english

now the data, i can view it and its correct

but the problem is that when i use the like statement to do the search operation

i use this sql:
Select * from Customers where CustomerName like N'%searchText%'

the customerName is of type nvarchar

now if i use one word then it gives me result, but if i use in the search two words (between them space) it dont work, or if i put one word then space it dont work

and in the same time if i copy the customerName from the table and search for it, it gives me the result, even if it was one word or two words or even three!!!

i belive there is a problem in the data, there is something in data i dont know what it is, but this is what it think, i changed the collation, but sometimes it got worst than that

SO IS THERE ANY ONE THAT CAN HELP!!!!!!

:)

thanks in advanceHi,
can you offer more details?
or can you paste your codes in?|||well yeah sure i can offer more details

This is the stored Procedure

CREATE PROCEDURE SP_Customers_GetAllRec

(
@.Searchfield as nvarchar(300)

)

AS
/* SET NOCOUNT ON */
select Customers.ID,CustomerName,RankID,StartDate,EndDate,Address,Username,Password,Email,EnteredBy,CustomerDiscount
from Customers inner join customerDiscount on Customers.CustomerDiscountID = CustomerDiscount.ID
where customername like '%'+@.SearchField+'%' order by CustomerName asc

RETURN
GO

and i send the @.Searchfield as an example N'Super' , this for an example

i tried to write the sql in many forms...but nothing worked!!!

anyone can help?|||Hi,
just to confirm with you, you are using SQL Server 2000?
the query for your statment is something like this format:
SELECT id FROM customer WHERE name like '%ab cd%'
while the query for variables is something like this format:
SELECT id FROM customer WHERE name like '%'+@.testing+'%'

what i dont understand is this :
@.Searchfield as an example N'Super'
if you are searching for the word 'Super', @.Searchfield 's value should be 'Super'
but if you are looking for the word " N'Super' ", i dont think sqlserver can do it because it will take the ' as a quote, thus making your select statment like this :
SELECT id FROM customer WHERE name like '%'N' Super''%'
which obviouslly leads to an error.

in my previous projects what i did was i converted the values ' to ", so that sqlserver will not mistake the quotes.
but of course it needs the assumptions that your data in that field shouldn't have any "s
and that you'll need some extra coding before you call your stored procedure.

Sorry if it didn't help you|||... the N is they way for SQL-Server to treat a string as Unicode instead of ASCII - the N would not be inserted in the LIKE clause.|||:: now if i use one word then it gives me result, but if i use in the search two words
:: (between them space) it dont work, or if i put one word then space it dont work

Ok, example string: "One Two Three".

if you want to find any one of the words "One", "Two", Three" you have to do one LIKE clause per word you try to find and combine them with OR, example:


SELECT
*
FROM
Table
WHERE
column LIKE '%ONE%'
OR column LIKE '%TWO%'
OR column LIKE '%THREE%'

... is that what you want to do? If not please post some sample data and search strings that work and that don't.

Hth,

Moon|||Hi All,

Thank you moon, but what the problem is ,its not that i want to find every word, the problem is when i try to find the 2 or 3 words together like :

select * from Table where column like '%one two three%'

all together, i dont know why there is space i cant find the word i want

this is the problem

thank you again|||Further thoughts are: are you sure you have a " " char in you strings? Since you did convert the data from a non-SQL server database, maybe you do not have a real space char that seperates the words but another char that will be displayed as a space (but having different keycode) and thus the query fails.

For testing you could try if one of the following searches will return records:

LIKE '%one%two%three%'
>> match the words in this order with any number of any other chars between them
LIKE '%one_two_three%'
>> match the words in this order with exactly one other chars between them

If so, then you have to find out which char is seperating them, by anylyzing the search result using the SQL-Server string functions for unicode.

Hth,

Moon|||I found some code in Books Online in the section explaining the ASCII function that you might be able to use to help you discover which characters are in your fields exactly. I adapted it slightly - you will need to change the line I have indicated in red:


SET TEXTSIZE 0
SET NOCOUNT ON
-- Create the variables for the current character string position
-- and for the character string.
DECLARE @.position int, @.string char(15)
-- Initialize the variables.
SET @.position = 1

-- change this line of code so that one record from your table is selected
SELECT @.string = somefieldcontainingspaces FROM sometable WHERE someuniquefield = someuniquevalue

WHILE @.position <= DATALENGTH(@.string)
BEGIN
SELECT ASCII(SUBSTRING(@.string, @.position, 1)),
CHAR(ASCII(SUBSTRING(@.string, @.position, 1)))
SET @.position = @.position + 1
END
SET NOCOUNT OFF


Normal spaces are ASCII character 32. Which character do you have in your field?

Terri|||hii

sorry i was in an urgent vacation

thank you tmorton i will check it and reply soon

Wednesday, March 7, 2012

problem with xml data source

hi,

i have a problem:

i got a report to which i pass a xml string like

<xml>

<somedata>

<somemoredata>

value

</somemoredata>

</somedata>

</xml>

in the visual studio it works just the way its supposed to be, but if i upload it on a report server and execute it there nothing happens. even no exception is thrown. the screen remains blank.

anyone got a solution or atleast a hint?

tia

found the problem:

the string i pass is only allowed to be about 1800 bytes large

Monday, February 20, 2012

problem with updateing foreign key to null value

Hi,
I was wondering if anyone out there can help me with the following problem:
I've written an annotated XSD for retrieving some related tables from
sql-server.
It's used in an XPATH Query that populates a strongly typed dataset
(generated using xsd.exe).
So far everyting works like a dream!
There is however one nagging problem i've encounterd so far. I'm trying to
"deassign" a child from it's parent by updating it's foreign key field to
null (by using the setnull method generated by xsd.exe).
The dataset records this but when I use it to try to update the database, no
update statements are executed and no errors are raised.
Updated the child with a different parent key does however work!!!
So it would seem SQLXML doesn't detect a change when updating to null?!
Any help would be greatly appreciated.
Regards, Rob HuibersHi Rob,
It is not clear which SQLXML API you are using? Are you using
SqlXmlAdapter and its Update method? Is it possible to post your schema so
that I can try to repro the issue here.
Thank you,
Amar Nalla
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> Hi,
> I was wondering if anyone out there can help me with the following
problem:
> I've written an annotated XSD for retrieving some related tables from
> sql-server.
> It's used in an XPATH Query that populates a strongly typed dataset
> (generated using xsd.exe).
> So far everyting works like a dream!
> There is however one nagging problem i've encounterd so far. I'm trying to
> "deassign" a child from it's parent by updating it's foreign key field to
> null (by using the setnull method generated by xsd.exe).
> The dataset records this but when I use it to try to update the database,
no
> update statements are executed and no errors are raised.
> Updated the child with a different parent key does however work!!!
> So it would seem SQLXML doesn't detect a change when updating to null?!
> Any help would be greatly appreciated.
> Regards, Rob Huibers|||Hi Amar,
Thanks for looking into the problem.
You're right in that I'm using SqlXmlAdapter.Update (SQLXML 3.0 sp3).
I've included the schema. The element I'm trying to nullify is
"sub_claim_id" belonging to parent "xyz_assigned_part_claim".
As I've mentioned before, the dataset record records the change but does not
serialize it to the database. When I generate an XmlDataDocument from the
dataset the sub_claim_id" element does not exist anymore. I would have
expected the element appearing with the "xsi:nil" attribute.
Hope you can figure it out, regards, Rob
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="ClaimSubclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_sub_claim"
child-key="claim_id" />
<sql:relationship name="ClaimSubclaimPartclaims" parent="xyz_sub_claim"
parent-key="sub_claim_id"
child="xyz_part_claim" child-key="sub_claim_id" />
<sql:relationship name="ClaimPartclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_part_claim"
child-key="claim_id" />
<sql:relationship name="ClaimTasks" parent="xyz_claim"
parent-key="claim_id" child="xyz_task"
child-key="claim_id" />
<sql:relationship name="SubclaimTasks" parent="xyz_sub_claim"
parent-key="sub_claim_id" child="xyz_task"
child-key="sub_claim_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType name="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:element name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:element name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
nillable="true" minOccurs="1" />
<xsd:element name="description" sql:field="description" type="xsd:string"
/>
</xsd:sequence>
</xsd:complexType>
<xsd:attributeGroup name="xyz_part_claim_investigation_type">
<xsd:attribute name="part_claim_investigation_id"
sql:field="part_claim_investigation_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" />
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_investigation_type">
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_task_type">
<xsd:attribute name="task_id" sql:field="task_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="type" sql:field="type" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
<xsd:attribute name="creator" sql:field="creator" type="xsd:string" />
<xsd:attribute name="performer" sql:field="performer" type="xsd:string" />
<xsd:attribute name="status" sql:field="status" type="xsd:int" />
<xsd:attribute name="date_started" sql:field="date_started"
type="xsd:dateTime" />
<xsd:attribute name="date_closed" sql:field="date_closed"
type="xsd:dateTime" />
<xsd:attribute name="date_created" sql:field="date_created"
type="xsd:dateTime" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
/>
</xsd:attributeGroup>
<xsd:element name="xyz_claims" sql:is-constant="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim" sql:key-fields="claim_id"
sql:relation="xyz_claim">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task" sql:relationship="ClaimTasks"
sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_sub_claim" sql:key-fields="sub_claim_id"
sql:relation="xyz_sub_claim"
sql:relationship="ClaimSubclaims">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_sub_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task"
sql:relationship="SubclaimTasks">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_assigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimSubclaimPartclaims">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_unassigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimPartclaims" sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_unassigned_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
"Amar Nalla [MS]" wrote:

> Hi Rob,
> It is not clear which SQLXML API you are using? Are you using
> SqlXmlAdapter and its Update method? Is it possible to post your schema so
> that I can try to repro the issue here.
> Thank you,
> Amar Nalla
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> "Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
> news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> problem:
> no
>
>