SQL Server backend problem (1 Viewer)

hima193

Registered User.
Local time
Today, 07:14
Joined
Aug 29, 2018
Messages
23
I have an access frontend linked to sql server backend
All worked good until i tried to put where condition in nvarchar field
Query result is always nothing

BS all my inputs are in Arabic but everything else is in English

I dont know where is the problem but i cant solve it
Any help will be appreciated.. thanks

Edit:
This is the sql statement

SELECT FullName FROM tblContacts WHERE FullName Like “محمد*”;
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 05:14
Joined
Jan 14, 2017
Messages
18,209
We can't work with nothing.
Please post the query SQL for someone to look at.
 

hima193

Registered User.
Local time
Today, 07:14
Joined
Aug 29, 2018
Messages
23
ok bro i added it
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:14
Joined
Oct 29, 2018
Messages
21,455
Hi. Just a thought... try using % instead of * as your wildcard character.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:14
Joined
Feb 28, 2001
Messages
27,148
I would have to guess to understand which characters are involved here. I might try a different approach:

SELECT Fullname FROM tblContacts WHERE Left( Fullname, n ) = "{whatever}" ;

However, I recall hearing that Arabic reads right to left. If so, then you might really need to use the Right function rather than the Left function because I cannot tell whether that is actually a request to find names beginning with whatever that was, or ENDING with whatever it was. In either case, when dealing with a non-English alphabet, wildcarding might become interesting but selection of sub-sets should still work normally.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 00:14
Joined
Apr 27, 2015
Messages
6,321
I think the DBGuy’s suggestion will do the trick, especially if you are doing a Pass Through Query. Had the same issue until a Google Search set me on the right path...
 

hima193

Registered User.
Local time
Today, 07:14
Joined
Aug 29, 2018
Messages
23
I tried even finding any letter in the field it always return nothing
 

hima193

Registered User.
Local time
Today, 07:14
Joined
Aug 29, 2018
Messages
23
An important thibg i have to mention that if i tried to import the table to access the query works
 

AccessBlaster

Registered User.
Local time
Yesterday, 21:14
Joined
May 22, 2010
Messages
5,920
I have an access frontend linked to sql server backend
All worked good until i tried to put where condition in nvarchar field
Query result is always nothing

BS all my inputs are in Arabic but everything else is in English

I dont know where is the problem but i cant solve it
Any help will be appreciated.. thanks

Edit:
This is the sql statement

SELECT FullName FROM tblContacts WHERE FullName Like “محمد*”;


Dealing with NULLS and nvarchar fields in the backend might be different, especially if your using microsoft management studio to write the SQL statement. Just a guess.
 

hima193

Registered User.
Local time
Today, 07:14
Joined
Aug 29, 2018
Messages
23
Dealing with NULLS and nvarchar fields in the backend might be different, especially if your using microsoft management studio to write the SQL statement. Just a guess.

I am writing the sql statment in access and it dosnt work
If i tried ssms it works if i pu in N before the text
Like this. Like N’ ’
 

AccessBlaster

Registered User.
Local time
Yesterday, 21:14
Joined
May 22, 2010
Messages
5,920
I am writing the sql statment in access and it dosnt work
If i tried ssms it works if i pu in N before the text
Like this. Like N’ ’

hima193, it looks like Solo712: hinted at this in his link: also here is more information on using the N prefix.

https://softwareengineering.stackexchange.com/questions/155859/why-do-we-need-to-put-n-before-strings-in-microsoft-sql-server

By default SQL server uses the Windows-1252 character codes for varchar. It contains most of characters for latin-based languages (English, German, French, etc.) But it does not contain characters for non-latin based languages (Polish, Russian, etc.). As stated by @Pieter B, nvarchar is used to get around that issue because it is for Unicode which contains those missing characters. This comes at a cost, it takes twice as much space to store nvarchar than varchar.
Putting N in front of your string ensures the characters are converted to Unicode before being placed into a nvarchar column. Most of the time you will be okay leaving the N off, but I wouldn't recommend it. It is a lot better to be safe than sorry.

HTH
 

Users who are viewing this thread

Top Bottom