Solved

MSSQL 2005 - Check lenght of a varchar field

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# DataTable (in memory) vs SQL Lookups 4 37
SQL- GROUP BY 4 25
SQL Syntax 6 42
SSRS Page Header from Group Data 2 29
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…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

730 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