423,688 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

Equivalent of "Startswith", "Endswith", "Contains" string comparisons in t-sql?

P: n/a
Hi,

I would like to select records from a table where the following criteria
hold:

SELECT * from Mytable where

field x "contains" string @X

or

field x "starts with" string @X

or

field x "ends with" string @X

What would the syntax for the "LIKE" predicate be in each of these
instances?
Thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I got it:

startswith: WHERE x LIKE @Value + '%'

endswith: WHERE x LIKE '%' + @Value

contains: WHERE x LIKE '%' + @Value + '%'

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:c7*******************@news.demon.co.uk...
Hi,

I would like to select records from a table where the following criteria
hold:

SELECT * from Mytable where

field x "contains" string @X

or

field x "starts with" string @X

or

field x "ends with" string @X

What would the syntax for the "LIKE" predicate be in each of these
instances?
Thanks.

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.