Subject | Comparison that detects diff in trailing blanks? |
---|---|

Author | Kjell Rilbe |

Post date | 2007-08-23T05:48:12Z |

Hi,

Since Firebird and the SQL standard says that = and <> shouldn't care

about trailing blanks in varchar fields, what is the recommended way to

compare varchar values so that differences in trailing blanks are detected?

I can see a few ways:

1. where F1 || 'X' <> F2 || 'X'

2. where F1 not like F2

I assume 1 can't use any indexes. But 2 will have problems if F2

contains wildcards % or _.

So, is there a way that both can use indexes and works with all possible

values in both F1 and F2?

Thanks,

Kjell

--

--------------------------------------

Kjell Rilbe

DataDIA AB

E-post: kjell@...

Telefon: 08-761 06 55

Mobil: 0733-44 24 64

Since Firebird and the SQL standard says that = and <> shouldn't care

about trailing blanks in varchar fields, what is the recommended way to

compare varchar values so that differences in trailing blanks are detected?

I can see a few ways:

1. where F1 || 'X' <> F2 || 'X'

2. where F1 not like F2

I assume 1 can't use any indexes. But 2 will have problems if F2

contains wildcards % or _.

So, is there a way that both can use indexes and works with all possible

values in both F1 and F2?

Thanks,

Kjell

--

--------------------------------------

Kjell Rilbe

DataDIA AB

E-post: kjell@...

Telefon: 08-761 06 55

Mobil: 0733-44 24 64