Logo

SQL Server STARTSWITH Function

Updated 2023-11-10 16:24:43.687000

Description

Use the scalar function STARTSWITH to determine if a string starts with a particular value.

Syntax

SELECT [westclintech].[wct].[STARTSWITH] (
  <@Text, nvarchar(max),>
 ,<@Value, nvarchar(max),>
 ,<@CaseSensitive, bit,>)

Arguments

@Text

is the 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 Type

bit

Remarks

STARTSWITH does not support the use of wildcards.

STARTSWITH supports case sensitive searches. @CaseSensitive = 1, makes the search case sensitive.

Examples

select wct.STARTSWITH('Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.'
,'Four '
,0);

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1"}]}