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

How to get the content length of TEXT Field in SQLServer Database

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

Share

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

This article is about how to get the content length of TEXT field in SQLServer database. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

What are the methods for SQLServer database to obtain the content length of TEXT field?

DATALENGTH is used to return the number of bytes occupied by any expression.

Syntax: DATALENGTH (expression)

Parameter: expression, any type of expression.

Return type: int

Note: DATALENGTH is particularly useful for varchar, varbinary, text, image, nvarchar, and ntext data types because these data types can store variable length data. The result of NULL's DATALENGTH is NULL.

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

What are the methods for SQLServer database to obtain the content length of TEXT field?

Use the example

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

USEpubsGOSELECTlength=DATALENGTH (pub_name), pub_nameFROMpublishersORDERBYpub_nameGO

Here is the result set:

Lengthpub_name---20AlgodataInfosystems16Binnet&Hardley21FiveLakesPublishing5GGG&G18LucernePublishing14NewMoonBooks17RamonaPublishers14ScootneyBooks

The above is how to obtain the content length of the TEXT field in the SQLServer database. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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