Solved

delete where the length of varchar < 10

Posted on 2008-10-12
1
275 Views
Last Modified: 2012-08-14
hi
i have one table  (int id , varchar(20) name)

how can i delete a record from database where length of name < 10
 i mean i want to delete it where it's less than 10 characters
thanks
0
Comment
Question by:klay8
1 Comment
 
LVL 3

Accepted Solution

by:
furrybootsistheanswer earned 500 total points
ID: 22699611
You can use this to determine the length of the name;
len([name])

if you have trailing spaces, you may want to trim the field;
len(rtrim([name]))

So your statement to delete would be;

delete from <tablename> where len([name]) < 10

or

delete from <tablename> where len(rtrim([name])) < 10

You should run this as a select first to make sure you get the expected rows;
select * from <tablename> where len([name]) < 10
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Creating and Managing Databases with phpMyAdmin in cPanel.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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