ReadVitamin

Blogging on Teradata SQL and More

5 Comments

mygif
Said in Monday, July 30th, 2007 @3:33 pm  

This is great, this is exactly what I was looking for. Thanks

mygif
tintin Said in Tuesday, January 15th, 2008 @4:19 am  

how to case sensitive in like search

mygif
admin Said in Tuesday, January 15th, 2008 @10:14 pm  

Hi Tintin,

If you are in Teradata mode then you do not have to worry as in Teradata mode, database is not case sensitive. Only if you are in ANSI mode, you need to write exact case. For example, if you have first name as tintin in a database, then LIKE ‘tin%’ would return “tintin” both in Teradata as well as ANSI mode but LIKE ‘Tin%’ would only return in Teradata mode.

Hope that helps.

mygif
Seemit Said in Monday, February 18th, 2008 @12:31 pm  

I want a SQL LIKE on a column say (EMP_ID varchar(30)) where EMP_ID contains a blank space anywhere in it. I did following

… emp_id like ‘%_ %’ — dint work.

any idea?

mygif
admin Said in Monday, February 18th, 2008 @7:57 pm  

Hi Seemit,

Try this one, most of the time we do have padding after the value and that is the reason LIKE might not give you what you want. Using TRIM functions removes unwanted paddings.

SELECT ‘This is Teradata’ COL1
WHERE RTRIM(LTRIM(col1)) LIKE ‘% %’

The above would return

COL1
This is Teradata

SELECT ‘Teradata’ COL1
WHERE RTRIM(LTRIM(col1)) LIKE ‘% %’

The above would NOT return anything. Following example with full syntax.

SELECT emp_id
FROM [table_name]
WHERE RTRIM(LTRIM([emp_id])) LIKE ‘% %’

Hope this helps.

Leave Your Comments Here

Popular Articles