Solved

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

Posted on 2008-10-23
4
786 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
  • 3
4 Comments
 
LVL 37

Expert Comment

by:momi_sabag
Comment Utility
are words separated by blanks?
0
 
LVL 7

Expert Comment

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

Expert Comment

by:momi_sabag
Comment Utility
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 500 total points
Comment Utility
sorry
it should be
select
  len(your_column) - len(replace(your_column, ' ', '')) + 1
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now