LIKE with numbers

LIKE with numbers

am 23.10.2007 17:52:21 von SReed

Hi,

I am trying to use a LIKE statement in a query to return all records with
certain numbers but I can't seem to get the syntax right.

Here it is with characters:

WHERE (State LIKE COALESCE (@State, N'%') + '%') AND (Name LIKE '%' +
COALESCE (@Name, N'') + '%') AND (City LIKE '%' + COALESCE (@city, N'') + '%')

AND (Address LIKE '%' + COALESCE (@Address, N'') + '%')

I want to do this with numbers such as CustomerID, OrderID and ShipperID.

--
Message posted via http://www.accessmonster.com

Re: LIKE with numbers

am 23.10.2007 18:25:40 von Rich P

You can't use Like with numbers. The Like keyword only works with data
types that support wildcards like * or % which would be varchar/text
string data types only. You can't use Like with Dates either. You can
only use Between or < and > with numbers and Dates.

Note: if a numeric value happens to be in a varchar/text field then
that value is really a string value which wouuld support wildcards.
They you can use Like, except you can't perform calculations with those
values since they are really strings. Examples would be zipcodes and
phone numbers.

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Re: LIKE with numbers

am 23.10.2007 18:37:33 von SReed

Thanks Rich, the values I am trying to work with are integers and that is why
I keep getting the error instead of my syntax.

--
Message posted via http://www.accessmonster.com