Solved

MSSQL 2005 - Check lenght of a varchar field

Posted on 2007-11-29
2
703 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server 2012 - Merge Replication Issue 1 23
VB.net and sql server 4 36
Passing Parameter to Stored Procedure 4 24
Present Absent from working date rage 11 21
Read about achieving the basic levels of HRIS security in the workplace.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

803 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