?
Solved

I want to count the total number of characters in a single column in SQL SERVER

Posted on 2008-10-23
4
Medium Priority
?
795 Views
Last Modified: 2012-05-05
I have a User table. I wish to calculate the total number of words in the user description column. For e.g. if in a user table I have user id=1 , Username=gurbir, User description='testing'. Now I want a program or method through which I can count the total number of words in the description column. Kindly suggest?
0
Comment
Question by:Gurbirs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 22784979
are words separated by blanks?
0
 
LVL 7

Expert Comment

by:Norush
ID: 22784989
SELECT     { fn LENGTH(FieldName) } AS LengthOfFieldName
FROM         TableName
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 22784998
assuming each word is seperated by a single blank

select
  len(your_column) - len(replace(your_column, ' ', ''))
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 2000 total points
ID: 22785002
sorry
it should be
select
  len(your_column) - len(replace(your_column, ' ', '')) + 1
0

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question