CASE WHEN - Adding collate into it.

Good morning,

Tried a few ways and I can ge this to work at the end in then WHEN part. Just struggling to put this together to be accepted as a CASE WHEN statement, probably missing the obvious.

Case when Postcode like '%[abcdefghijklmnopqrstuvwxyz%]' then 'Lowercase Postcode' else 'Postcode OK' end as [DQPostcode]
   
collate Latin1_General_CS_AS

Simple terms looking for all instances of Lowercase characters in the Postcode field

August 20th, 2015 3:22am

Hi 

The like statement  is not like a regex expression so you statement is looking for the full string and not just a part on it.

There are a few ways to do what you are looking at by breaking the string down in to characters and checking them one at a time, however a simple cheat that achieves what i thing you are after is

DECLARE @val VARCHAR(255) = 'TEST1'
SELECT CASE WHEN BINARY_CHECKSUM(@val) = BINARY_CHECKSUM(upper(@val)) THEN 'Postcode OK' ELSE 'Lowercase Postcode' END 

set @val = 'Test1'
SELECT CASE WHEN BINARY_CHECKSUM(@val) = BINARY_CHECKSUM(upper(@val)) THEN 'Postcode OK' ELSE 'Lowercase Postcode' END 

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 3:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics