Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of DATALENGTH in SQL

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "the use of DATALENGTH in SQL". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the use of DATALENGTH in SQL".

Returns the number of bytes occupied by any expression.

Grammar

DATALENGTH (expression)

Parameters.

Expression

Any type of expression.

Return type

Int

Annotation

DATALENGTH is particularly useful for varchar, varbinary, text, image, nvarchar, and ntext data types because these data types can be stored

Variable length data.

The result of NULL's DATALENGTH is NULL.

Indicates that the compatibility level may affect the return value. For more information about compatibility levels, see sp_dbcmptlevel.

Example

This example finds the length of the pub_name column in the publishers table.

USE pubs

GO

SELECT length = DATALENGTH (pub_name), pub_name

FROM publishers

ORDER BY pub_name

GO

Here is the result set:

Length pub_name

20 Algodata Infosystems

16 Binnet & Hardley

21 Five Lakes Publishing

5 GGG&G

18 Lucerne Publishing

14 New Moon Books

17 Ramona Publishers

14 Scootney Books

(8 row (s) affected)

At this point, I believe you have a deeper understanding of "the use of DATALENGTH in SQL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report