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

x
?
Solved

MSSQL 2005 - Check lenght of a varchar field

Posted on 2007-11-29
2
Medium Priority
?
715 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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

916 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