Solved

use SQL to find data with a fixed data length within column

Posted on 2011-09-18
3
220 Views
Last Modified: 2012-05-12
column( A) in a database of datatype nchar with a data length of 32 i.e. nchar(32)

can some suggest suggest SQL to find rows with data length of fixed 30 characters in this column A?

Cheers
GMac
0
Comment
Question by:gerrymac1943
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 500 total points
ID: 36556854
This should work:

SELECT * FROM table_name WHERE LEN(columnA) = 30
0
 
LVL 13

Expert Comment

by:jonnidip
ID: 36556864
Maybe you will need to add ltrim and rtrim to your column;
select * from table where len(ltrim(rtrim(columnA))) = 30
0
 

Author Closing Comment

by:gerrymac1943
ID: 36556875
genius
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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…

630 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