Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 797
  • Last Modified:

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

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
Gurbirs
Asked:
Gurbirs
  • 3
1 Solution
 
momi_sabagCommented:
are words separated by blanks?
0
 
NorushCommented:
SELECT     { fn LENGTH(FieldName) } AS LengthOfFieldName
FROM         TableName
0
 
momi_sabagCommented:
assuming each word is seperated by a single blank

select
  len(your_column) - len(replace(your_column, ' ', ''))
0
 
momi_sabagCommented:
sorry
it should be
select
  len(your_column) - len(replace(your_column, ' ', '')) + 1
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now