Solved

SQL needed to find character length for each record of a field

Posted on 2008-06-23
3
1,851 Views
Last Modified: 2008-06-23
Hi, I need to run a query that will tell the length of characters for each record; so:
fieldA = somedata
fieldB = somemoredata
Then the query would return:
fieldA = 8
fieldB = 12
Can anyone assist?
0
Comment
Question by:jimshock
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 21849442
select len(fieldA), len(fieldB) from yourtable
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21849443
something like this...you'll need to do it for each field

select len(ltrim(rtrim(fieldname)))
from yourtablename
0
 

Author Comment

by:jimshock
ID: 21849491
Thanks!!!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

685 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