字符串规范函数 (Entity SQL)

Entity SQL 包含字符串规范函数。

备注

下表列出了字符串 Entity SQL 规范函数。

函数 说明

Concat (string1, string2)

返回包含追加了 string1 的 string2 的字符串。

参数

String

返回值

String。如果返回值字符串的长度大于允许的最大长度,则发生错误。

示例

-- The following example returns abcxyz.

Concat('abc', 'xyz')

IndexOf(string1, string2)

返回 string1 在 string2 中的位置,如果没找到则返回 0。返回 1 指示字符串的起始位置。索引号从 1 开始。

参数

String

返回值

Int32

示例

-- The following example returns 4.

IndexOf('xyz', 'abcxyz')

Left (string, length)

返回 string 左侧开始的前 length 个字符。如果 string 的长度小于 length,则返回整个字符串。

参数

string:String

length:Int16Int32Int64Byte。length 不能小于零。

返回值

String

示例

-- The following example returns abc.

Left('abcxyz', 3)

Length (string)

返回字符串的 (Int32) 长度,以字符为单位。

参数

string:String

返回值

Int32

示例

-- The following example returns 6.

Legth('abcxyz')

LTrim(string)

返回没有前导空白的 string。

参数

String

返回值

String

示例

-- The following example returns abc.

LTrim(' abc')

Replace (string1, string2, string3)

返回 string1,其中所有 string2 都替换为 string3。

参数

String

返回值

String

示例

-- The following example returns abcxyz.

Concat('abc', 'xyz')

Reverse (string)

返回反转字符顺序的 string。

参数

String

返回值

String

示例

-- The following example returns dcba.

Reverse('abcd')

Right (string, length)

返回 string 的后 length 个字符。如果 string 的长度小于 length,则返回整个字符串。

参数

string:String

length:Int16Int32Int64Byte。length 不能小于零。

返回值

String

示例

-- The following example returns xyz.

Right('abcxyz', 3)

RTrim(string)

返回没有尾随空白的 string。

参数

String

返回值

String

Substring (string, start, length)

返回字符串的从 start 位置开始、长度为 length 个字符的子字符串。start 为 1 指示字符串的第一个字符。索引号从 1 开始。

参数

string:String

start:Int16Int32Int64Byte。start 不能小于一。

length:Int16Int32Int64Byte。length 不能小于零。

返回值

String

示例

-- The following example returns xyz.

Substring('abcxyz', 4, 3)

ToLower(string)

返回全部大写字符都转换为小写字符的 string。

参数

String

返回值

String

示例

-- The following example returns abc.

ToLower('ABC')

ToUpper(string)

返回全部小写字符都转换为大写字符的 string。

参数

String

返回值

String

示例

-- The following example returns ABC.

ToUpper('abc')

Trim(string)

返回没有前导空白和尾随空白的 string。

参数

String

返回值

String

示例

-- The following example returns abc.

Trim(' abc ')

如果提供 Null 输入,则这些函数返回 Null

Microsoft SQL 客户端托管提供程序中提供了等效功能。有关更多信息,请参见 用于实体框架函数的 SQL Server .NET Framework 数据提供程序 (SqlClient)

另请参见

概念

规范函数 (Entity SQL)