Query to get the length of string in ms sql server

In this programming tutorial you will learn the query that will get the length of string in ms sql server. It is quite easy in ms sql server. Let's have a look over it.

Query to get the length of string in ms sql server

select len('Arman Malik') as length;

Output
11

The above query will give you 12 as output because there are total 11 characters including space found in string.

That's it. Using built-in len() function of ms sql server you can do this very easily. In case if there is any apostrophe in string then you have to use another apostrophe before it like illustrated in example given below
select len('Arman Malik''s passion is programming') as length;
Output:-
37

I hope you will found this tutorial very handy and informative.

I love your feedback.

0 comments: