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

x
?
Solved

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

Posted on 2011-09-18
3
Medium Priority
?
223 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

972 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