Sql server contains

I need to combine on a partial line, but I can’t enable full-text indexing, so I can’t use contains. I looked at the Levenshtein function to determine the distance between two rows, but I'm not looking for a fuzzy match, but every character in the column exists in the row.

those. If the transmitted row is something like AB_SYS_20120430.TXT, I want to match any columns containing AB_SYS. A similar predicate does not get me there. I really need the equivalent of a .NET function, but as mentioned, the inclusion of full-text indexing is not a possibility of inclusion. I thought I'd see if there was any other work.

+3
source share
2 answers

LIKE?
http://www.w3schools.com/sql/sql_like.asp

... WHERE MyColumn LIKE '%AB_SYS%'

, , ... , .

String.Contains
http://msdn.microsoft.com/en-us/library/dy85x1sa.aspx

EDIT:. "" ?

: LIKE, , :

... WHERE 'AB_SYS_20120430.TXT' LIKE '%' + MyColumn + '%'

: , . , , , :

MyTable
MyColumn
"AB_SYS" MyColumn

"AB_SYS_20120430.TXT",

CREATE PROCEDURE MyTestProcedure 
    @pFullNameString nvarchar(4000) = '' -- parameter passed in, like AB_SYS_20120430.TXT
AS
BEGIN
    SELECT
        *
    FROM
        MyTable
    WHERE
        @pFullNameString LIKE '%' + MyTable.[MyColumn] + '%'
END
GO
+5

CHARINDEX

WHERE  CHARINDEX(StringToCheckFor, StringToCheckIn) > 0
+2

All Articles