I have a table with few columns in SQLite. I have two columns that I need to use for querying this table (code, Description). Both of these have the COLLATE NOCASE
when creating the tables as below:
CREATE TABLE [AuditEvent] (
"Code" char(4) NOT NULL COLLATE NOCASE,
"Description" nvarchar(255) NOT NULL COLLATE NOCASE,
"AuditEventPK" guid NOT NULL,
PRIMARY KEY ([Code])
);
When I query the table using the code I get no results
select * from auditevent where code = 'add' -- does not return any value
select * from auditevent where description = 'add' -- returns the right record.
However when I query the table using the description colomun, I get the results.
In some cases, I have to use the CODE, but it is not returning anything. Any idea??
Code
is set tochar(4)
So it would be'add '
with a trailing space. – Silvermindvarchar
is as it's name already implies is variable in length, whilechar
is not.char
is always a fixed size. The value will be padded at the right side with spaces if you did not provide enough characters. – Silvermind