Solved

delete where the length of varchar < 10

Posted on 2008-10-12
1
274 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Creating and Managing Databases with phpMyAdmin in cPanel.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

14 Experts available now in Live!

Get 1:1 Help Now