开发者

SQL Server statement Where myfield content giving sub-string

开发者 https://www.devze.com 2023-01-06 05:41 出处:网络
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:

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

精彩评论

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