SQL LEN() 语法

SELECT LEN(column_name) FROM table_name

Id

LastName

FirstName

Address

City

1

Adams

John

Oxford Street

London

2

Bush

George

Fifth Avenue

New York

3

Carter

Thomas

Changan Street

Beijing

现在,我们希望取得 "City" 列中值的长度。

我们使用如下 SQL 语句:

SELECT LEN(City) as LengthOfCity FROM Persons

结果集类似这样:

LengthOfCity

6

8

7