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

Posted on 2008-10-23
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?
Question by:Gurbirs
  • 3
LVL 37

Expert Comment

ID: 22784979
are words separated by blanks?

Expert Comment

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

Expert Comment

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

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

Accepted Solution

momi_sabag earned 500 total points
ID: 22785002
it should be
  len(your_column) - len(replace(your_column, ' ', '')) + 1

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle Stored Procedure for User Account data 2 28
Help with query 3 25
ServiceCenter IR Query Expressions 1 18
error in my cursor 5 29
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

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