x

Using LIKE filter in SQL

Hello,

I'm really new to SQL so please feel free to laugh at my ridiculous question. I am more than proficient with VBA and thought it would translate, however it doesn't always seem to be the case.

I have built a view and in it I need to filter by LIKE 'appropriate'. I have tried a variety of different ways and it keeps giving me NULL results, which isn't true because I exported to Excel and can see several results there.

I would be grateful if you could advise. At the moment it looks like this (cant include all statement due to data protection stuff)

WHERE (ARCHV_FLAG = N'n') AND (CREATE_DTTM > CONVERT(DATETIME, '2014-04-01 00:00:00', 102)) AND (DIM_LOOKUP_CASNT_TYPE_ID_DESC = N'case note') AND (TITLE = N'LIKE APPROPRIATE')

I realise this is probably simple, but I am getting more than a little frustrated at it not working and would be really grateful if someone could help!

Thanks in advance

Nic (hopelessly new to all this)

more ▼

asked Mar 23, 2015 at 03:50 PM in Default

avatar image

Nixxienic
11 3

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Do you mean

 ... AND Title like '%appropriate%'

in other words, are you searching for an occurrence of 'appropriate' in the Title column?

more ▼

answered Mar 23, 2015 at 03:52 PM

avatar image

Kev Riley ♦♦
65.8k 48 63 81

Hi, yes thats exactly what I am looking for. It just doesnt seem to return the results when I do that.

Mar 23, 2015 at 03:59 PM Nixxienic

Unfortunately that hasn't worked, it tells me that it can't Parse. Is there anyway around this?

Mar 23, 2015 at 04:17 PM Nixxienic

Please post your updated WHERE clause.

Mar 23, 2015 at 05:31 PM KenJ

WHERE (ARCHV_FLAG = N'n') AND (CREATE_DTTM > CONVERT(DATETIME, '2014-04-01 00:00:00', 102)) AND (DIM_LOOKUP_CASNT_TYPE_ID_DESC = N'case note') AND (TITLE LIKE N'%APPROPRIATE%')

Mar 24, 2015 at 12:31 PM Sule

and when you say "it tells me it can't Parse" what does? What is the error message? And what application are you using to type this SQL query ?

Mar 24, 2015 at 12:36 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x67
x24
x21

asked: Mar 23, 2015 at 03:50 PM

Seen: 75 times

Last Updated: Mar 30, 2015 at 12:09 PM

Copyright 2017 Redgate Software. Privacy Policy