开发者

SQL Server statement Where myfield content giving sub-string

I'm looking for a SQL Server statement to retrieve records Wh开发者_JS百科ere myfield content giving sub-string.


Another possibility is to use LIKE:

SELECT
    MT.column_1,
    ....
FROM
    My_Table MT
WHERE
    some_column LIKE '%' + @search_string + '%'


You can use CharIndex

Select * From YourTable
Where
CharIndex('yoursubstring', myfield) > 0


Try PatIndex.

SELECT *
FROM Table
WHERE patindex('%string%', data ) > 0


select * from mytable where myfield like '%literalstring%'

or

select * from mytable where myfield like '%' + @stringvar + '%'

...not really clear on whether your substring is a literal or a variable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜