Solved

delete where the length of varchar < 10

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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 …
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 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