Solved

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

Posted on 2011-09-18
3
213 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
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

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
SQL Update trigger 5 18
SQL Server 2012 - Merge Replication Issue 1 22
Sql Server group by 10 27
Proper Case SQL Command 2 9
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…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

777 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