• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 718
  • Last Modified:

MSSQL 2005 - Check lenght of a varchar field


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! :)
1 Solution
Aneesh RetnakaranDatabase AdministratorCommented:
Hello Endelm,

SELECT * FROM NamesTest WHERE LEN(Name) > 5

Aneesh R
EndelmAuthor Commented:
Thank you :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now