获取 SQL Server Image Text ntext数据长度
来源:互联网 发布:摩托分期付款怎么算法 编辑:程序博客网 时间:2024/06/05 05:03
How to get length of Text, NText and Image columns in SQL Server
By: Greg Robidoux | Read Comments (4) | Related Tips: More > Data TypesProblem
There is sometimes a need to figure out the maximum space that is being used by a particular column in your database. You would initially think that the LEN() function would allow you to do this, but this function does not work on Text, NText or Image data types, so how do you figure out the length of a value in a column that has one of these data types?
Solution
In addition to the LEN() function, SQL Server also has a DATALENGTH() function. This function can be used on all data types in your table.
Here is an example of running these commands on an IMAGE data type using the LEN function:
SELECT name, LEN(packagedata)
FROM dbo.sysdtspackages
query results
Here is an example of running these commands on an IMAGE data type using the DATALENGTH function:
SELECT name, DATALENGTH(packagedata)
FROM dbo.sysdtspackages
query results
If you wanted to find out the maximum length used for all of your records you could issue a command such as the following:
SELECT TOP 1 name, DATALENGTH(packagedata)
FROM dbo.sysdtspackages
ORDER BY 2 DESC
That is all there is to it. Another little function that you probably won't use often, but this is helpful to know it is there when you do need to use it.
Next Steps
- Add this command to your SQL Server T-SQL toolbox
- Take a look at these other useful T-SQL functions
- SQL Server 2000 Text Data Manipulation
- Date/Time Conversions Using SQL Server
- Retrieving SQL Server Index Properties with INDEXPROPERTY
- Retrieving SQL Server Database Properties with DATABASEPROPERTYEX
Last Update: 2/27/2007
- 获取 SQL Server Image Text ntext数据长度
- MS SQL Server 计算nText、Text、Image的字段的数据长度
- MS Sql Server存储image、text、ntext
- [转]Java在SQL Server写入text,ntext,image字段
- SQL中ntext、text 或 image 类型数据的处理
- SQL text ntext image 小问题
- 在SQL server 2000 中 如何更新表中的text、ntext 或 image 字段信息
- 如何判断sql server数据库中的image,text,ntext类型字段是否为NULL?
- SQL server 中更新表中的text、ntext或image字段信息
- 修改text/ntext/image 配置的最大长度65535
- text、ntext 和 image
- SQL Server 提示:text、ntext或image节点的页(1:XX),槽4不存在的解决方法
- SQL Server获取TEXT字段的内容长度
- ntext,image,text 中的替换
- Sql Server 中 text或ntext 字段内容替换
- SQL Server 2005数据类型char,varchar,text ,nchar,nvarchar,ntext
- 解决SQL Server的TEXT、IMAGE类型字段的长度限制
- 解决SQL Server的TEXT、IMAGE类型字段的长度限制
- java_web-HTML-3-01-12-2015
- sql中的if else 的一个小陷阱
- shell:读取文件的每一行内容并输出
- 开启LeetCode刷题模式~
- android ListView异步加载图片(双缓存)
- 获取 SQL Server Image Text ntext数据长度
- opencv安装及测试
- 二分法(PHP实现)
- 将Cocos2d-x的VS工程导入XCode
- Java5 并发学习
- python中repr和 str的异同
- GCD 总结
- ShareREC for Android 1.0.0已经发布
- cocos2dx windows下使用中文字符串乱码解决方案