Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Counting Characters in cells

Author  Topic 

liagrisj
Starting Member

9 Posts

Posted - 2010-03-12 : 10:43:22
I'm trying to figure out how to select and delete, out of a column, an exact number of characters.

Example: I have a column that is filled with people's first and last names. I want to delete cells that have a certain number of characters. So if my list was as follows:

eric brown
stephanie smith
corey monroe
jonathan stephenson

I need a statement that if I said to delete cells that had 12 or less characters, that eric brown and corey monroe would be deleted. The other two names would remain untouched.

Thanks a lot. I thought a simple google search would help...it did not.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-12 : 10:57:29
[code]DELETE t
FROM table t
WHERE LEN(Name)<=12
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

liagrisj
Starting Member

9 Posts

Posted - 2010-03-12 : 11:55:30
That worked well. Thank you so much!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-12 : 11:59:36
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -