Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server contains-string function


CONTAINSSTR

Updated: 30 April 2009

Use CONTAINSSTR to determine if a string contains a particular value.
Syntax
SELECT [wctString].[wct].[CONTAINSSTR] (
   <@Text, nvarchar(max),>
 ,<@Value, nvarchar(max),>
 ,<@CaseSensitive, bit,>)
Arguments
@Text
is the first text to be searched. The @Text argument can be of data types that are implicitly convertible to nvarchar or ntext.
 
@Value
is the value to search for in @Text. The @Value argument can be of data types that are implicitly convertible to nvarchar or ntext.
 
@CaseSensitive
declares the search as being either case sensitive or case insensitive, regardless of collation. The @CaseSenstive argument must be of data types that are implicitly convertible to bit.
 
Return Types
bit
Remarks
·         CONTAINSSTR does not support the use of wildcards.
·         CONTAINSSTR supports case sensitive searches. @CaseSensitive = 1, makes the search case sensitive.
Examples
 
select wct.CONTAINSSTR('four score', 'OU', 1)
 

This produces the following result
-----
0
 
(1 row(s) affected)
 
select wct.CONTAINSSTR('four score', 'OU', 0)
 

This produces the following result
-----
1
 
(1 row(s) affected)
 
select CHARINDEX('OU', 'four score')

This produces the following result
-----------
2
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service