Solved

MSSQL 2005 - Check lenght of a varchar field

Posted on 2007-11-29
2
702 Views
Last Modified: 2010-04-21
Hi,

I created a simple test:

create table dbo.NamesTest(
id int,
name varchar(200)
)

insert into dbo.NamesTest(id,name)
values(1, 'John Paul')

insert into dbo.NamesTest(id,name)
values(2, 'Simon Garfunkel')

insert into dbo.NamesTest(id,name)
values(3, 'Jimmy')

select * from dbo.NamesTest

1      John Paul
2      Simon Garfunkel
3      Jimmy
--------

How can I run a query that tells me if any [name] field is more than 5 characters in lenght (like nr. 1 and 2 are)?

Thank you! :)
0
Comment
Question by:Endelm
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 20374965
Hello Endelm,

SELECT * FROM NamesTest WHERE LEN(Name) > 5



Aneesh R
0
 

Author Closing Comment

by:Endelm
ID: 31411708
Thank you :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

948 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now