Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-23
3
Medium Priority
?
1,859 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 1200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

971 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