DATALENGTH function in SQL server is used to return the no of bytes used by the expression.
SYNTAX
DATALENGTH (EXPRESSION)
EXAMPLE
The following example demoanstrates the use of datalength function in SQL server.
In the above example i have passed the EmailAddress column to the DATALENGTH function.
In the Results tab the data_length column is showing the corresponding datalength for the row.
The emailaddress is nvarchar data-type and it takes 2 bytes per character, so it returns the value as double of the length column.
Using the above DATALENGTH function we can easily find the bytes used by the expression.
The bytes occupied per each character will be differ for different data-type.
No comments:
Post a Comment