Welcome -
Guest!
Login
/
Register Now
|
Search:
Home
Articles
Forum
Interview FAQ
Activities
News
Videos
Poll
Links
People
Groups
SQL Server Articles
Submit Article
Home
»
Articles
»
SQL Server
»
System Functions
RSS Feeds
DATALENGTH Function
Posted By:
Sarita Patel
Category:
SQL Server
Views:
4427
This article explains about DATALENGTH function in sql server with examples.
DATALENGTH function returns number of bytes used to represent specified expression.
It is a deterministic i.e It returns same value every time it is called with a specific set of values.
Syntax of DATALENGTH Function :
DATALENGTH (
expression
)
expression
is any valid sql server expression.
Return type
of DATALENGTH function is an integer.
Examples of DATALENGTH Function :
Example 1 : Use of DATALENGTH function in select clause
SELECT
DATALENGTH ( 'Syntax-Example' )
Output
14
Above example returns number of byte required for specified string.
Example 2 : Use of DATALENGTH function to display column value in select clause
SELECT ProductName,
DATALENGTH (ProductName) AS OccupiedLength
FROM Products
Output
ProductName
OccupiedLength
Chai
8
Chang
10
Aniseed Syrup
26
Chef Anton's Cajun Seasoning
56
Chef Anton's Gumbo Mix
44
Grandma's Boysenberry Spread
56
Uncle Bob's Organic Dried Pears
62
Northwoods Cranberry Sauce
52
Above example returns number of bytes used to represent productname of products table.
Share:
Previous Post:
CURRENT_USER Function
Next Post:
@@ERROR - ERROR Function
Didn't find what you were looking for? Find more on
DATALENGTH Function
Or get
search suggestion and latest updates
.
Sarita Patel
author of DATALENGTH Function is from
United States
.
View All Articles
Related Articles and Code:
Example 4 of using function and local variables in functions
Program of nesting member functions, private member functions and array of objects
Write a function to perform string operation i.e. split, join, length, substring using pointer without using any string function
Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception
Program to read numbers from two files using fscanf function and write it in another file using fprintf function in ascending order
Function to find the binary equivalent of a given decimal integer and display it
Program of matrix multiplication using function
Program of matrix addition using function
Program to find the length of a string taken from user without using strlen function
Program to create user defined fork function and create 2 child process, print their process ids
Program to implement Add and Subtract functions on Big Number Class
Program to illusrate data conversion user defined data types using functions
Program to illustrate the functions returning pointers
Program to illustrate passing structures to function
Program to illustrate over-riding of base class member function in a derived class
Program to interchange the values of two int , float and char using function templates
Program to estimate the Integral value of a given function using Gussian Quadrature Rule
Program to estimate the Differential value of the function using Euler Method
Program to estimate the Differential value of a given function using Runge-Kutta Methods
Program to determine whether the given function is a Cubic Spline or not
Other Interesting Articles in SQL Server:
INDEX_COL Function
Examples of / ( Divide ) Operator
DATEADD Function
DB_NAME Function
PI Function
SYSTEM_USER Function
@@IDLE - IDLE Function
@@VERSION - VERSION Function
Operators in SQL Server
@@PACK_RECEIVED - PACK_RECEIVED Function
@@TOTAL_ERRORS - TOTAL_ERRORS Function
Select Query
CHAR Function
LEN Function
DATEDIFF Function
CONVERT Function
SPACE Function
MONTH Function
CAST Function
Examples of % ( Modulo ) Operator
Please enter your Comment
*
*
Comment should be atleast 30 Characters.
Please put code inside [Code] your code [/Code].
Please login to post comment
No Comment Found, Be the First to post comment!
SQL Server
View All
Aggregate Functions
Analytical Functions
Configuration Function...
Constraints
Cursor
Cursor Functions
Data Control Language
Data Definition Lang
Data Manipulation Lang
Data Type
Database
Date Time Functions
Functions
Index
Interview FAQ
Joins
Math Functions
Meta Data Functions
Miscellaneous
Operator
Rowset Functions
Security Functions
Select Query
Sequence
Stored Procedures
String Functions
Sub Query
System Functions
System Statistical Fun...
Text and Image Functio...
Transaction Control La...
Trigger
View
Assembly Language
Artificial Intelligence
C Programming
C++ Programming
Visual C++
OOAD
Cobol
Java
Asp.net MVC
Rest and WCF Services
Entity Framework
Knockout.Js
Unix / Linux / Ubuntu
Networking
OOPs Concept
HTML
Dos
SQL
System Analysis & Design
Gadgets
Internet
CSS
Javascript
.Net Framework
Asp.net
C#
VB.Net
Python
Perl
Oracle
Software Engineering
RDBMS Terms
AJAX Framework
Design Pattern
UML
WPF
WCF
SEO
PowerShell
Visual Studio
WWF
BizTalk Server
Azure
General
Testing
Online Certifications
PHP
My SQL
LinQ
Project Management
Silverlight
XML
MS Office
Windows OS
DHTML
Sharepoint