By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,856 Members | 2,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,856 IT Pros & Developers. It's quick & easy.

how to work with macrons and ms sql 2000/2005

prabirchoudhury
100+
P: 162
Hello

I am working on macrons name fields in MSSQL 2000/2005 database and it is not working for the select where fiels is macron. sql could not understand the search the index for the macron field.

any one have any idea how to keep( different format) the macron record and search for that records ..
exam ple code below..

Expand|Select|Wrap|Line Numbers
  1. select * from student where first_name like '%Māori%'”
  2.  
thanks
Jan 13 '10 #1
Share this Question
Share on Google+
7 Replies


ck9663
Expert 2.5K+
P: 2,878
What error are you getting? Your code should return all records with first name with that string inside it.

~~ CK
Jan 13 '10 #2

prabirchoudhury
100+
P: 162
Hey CK
thanks for your reply. I am not getting any error but no match return but the matches are in the searching field. testing query is not making any error eather. any idea?

thanks again
Jan 13 '10 #3

prabirchoudhury
100+
P: 162
hello

INSERT INTO dbo.access (student_id,action, table_ref)
VALUES (100,'c', 'Māori')

here i cant insert "Māori" a macron on field into a table the datatype of the field is nvarchar(50)

any idea please, thanks
Jan 13 '10 #4

prabirchoudhury
100+
P: 162
Hello

1. I cant insert a macron on field 'Māori' it is not making any error but just taking the data without macron.
2. even a macron on field is present in the table bit the select query not getting any error but no match return but the matches are in the searching field.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO student(student_id,action, table_ref)
  2. VALUES (100,'c', 'Māori') 
  3. select * from student where first_name like '%Māori%'
  4.  
many thanks

Prabir
Jan 13 '10 #5

Frinavale
Expert Mod 5K+
P: 9,731
Try changing the first_name field so that it's a nvarchar type instead of a varchar type.

Apparently NVARCHAR is supports two-byte characters which is needed for non-English characters.

Check out this MSDN article on International Features in MS SQL Server 2005

**Edit**

I just re-read your post and apparently you are using nvarchar.
I'm not sure what's wrong....sorry

-Frinny
Jan 13 '10 #6

prabirchoudhury
100+
P: 162
hey Frinny thanks for your reply..
Jan 13 '10 #7

nbiswas
100+
P: 149
Use unicode

e.g.

Expand|Select|Wrap|Line Numbers
  1. declare @tbl table(field nvarchar(20))
  2. insert into  @tbl 
  3. select N'Māori' union all 
  4. select N'Maori' union all 
  5. select N'Some Māori' union all 
  6. select N'Some Maori'
Solution

Expand|Select|Wrap|Line Numbers
  1. select * from @tbl where field like N'%Māori%'

Output
Expand|Select|Wrap|Line Numbers
  1. field
  2. Māori
  3. Some Māori
If you need an exact match

try :
Expand|Select|Wrap|Line Numbers
  1. select * from @tbl where field = N'Māori'
Output

Expand|Select|Wrap|Line Numbers
  1. field
  2. Māori
Hope this helps
Feb 21 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.