Solved

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

Posted on 2008-10-23
4
790 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
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 500 total points
ID: 22785002
sorry
it should be
select
  len(your_column) - len(replace(your_column, ' ', '')) + 1
0

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