February 8, 2022 at 8:33 pm
We are setting up a new database. One ask is for students who want to display a non-Latin name are able to with latin chars in (). or Spanish accent like ó?
What options do we have, for example, use a special collation for db, or table, or column? If so, what collation to use?
or other options?
Thanks
February 8, 2022 at 10:24 pm
Not an expert, but it looks like you might want to use Modern_Spanish_CI_AS collation (case insensitive, but accent sensitive -- so a = A but à <> a).
e.g., for a database named "Mod_ES_CI_AI", the following appears to work:
ALTER DATABASE [Mod_ES_CI_AI] COLLATE Modern_Spanish_CI_AS;
GO
CREATE TABLE [dbo].[SpanishText](
[SpanishTextID] [int] IDENTITY(1,1) NOT NULL,
[SpanishText] [varchar](255) NOT NULL,
CONSTRAINT [PK_SpanishText] PRIMARY KEY CLUSTERED
(
[SpanishTextID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT INTO dbo.SpanishText (SpanishText)
VALUES ('A él le gusta el queso'),
('Te recomiendo que pruebes el té'),
('Sí, quiero ir al restaurante, pero solo si tienen pizza'),
('Quiero más chocolate, mas es mala idea.'),
('¿Donde esta el baño?'),
('ambigüedad');
INSERT INTO dbo.SpanishText (SpanishText)
VALUES ('A él le gusta el queso'),
('Te recomiendo que pruebes el té'),
('Sí, quiero ir al restaurante, pero solo si tienen pizza'),
('Quiero más chocolate, mas es mala idea.'),
('¿Donde esta el baño?'),
('ambigüedad');
SELECT * FROM dbo.SpanishText;
SELECT * FROM dbo.SpanishText WHERE SpanishText LIKE '%ü%';
SELECT * FROM dbo.SpanishText WHERE SpanishText NOT LIKE '%ü%';
SELECT * FROM dbo.SpanishText WHERE SpanishText LIKE '%u%';
SELECT * FROM dbo.SpanishText WHERE SpanishText NOT LIKE '%u%';
SELECT * FROM dbo.SpanishText WHERE SpanishText LIKE '%é%';
SELECT * FROM dbo.SpanishText WHERE SpanishText NOT LIKE '%é%';
SELECT * FROM dbo.SpanishText WHERE SpanishText LIKE '%e%';
SELECT * FROM dbo.SpanishText WHERE SpanishText NOT LIKE '%e%';
TRUNCATE TABLE dbo.SpanishText;
February 9, 2022 at 12:56 am
Thank you. It looks like the Modern_Spanish_CI_AS stored spanish mainly. What we want is still a database mostly stored English, but just for sometimes if users like to display their non-latin name in a () for example.
February 9, 2022 at 3:04 am
Thank you. It looks like the Modern_Spanish_CI_AS stored spanish mainly. What we want is still a database mostly stored English, but just for sometimes if users like to display their non-latin name in a () for example.
You don't have to make the whole database non-english nor do you have to make it case sensitive for just a few name columns. In most cases, NVARCHAR() will do the trick for you and if you want to make that column case sensitive, you could do that with with a binary collation or other collation just on the column(s) needed.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 9, 2022 at 3:40 pm
NVARCHAR for the win!
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply