Solved

How to update one column based on the length of data in another column

Posted on 2014-03-05
2
186 Views
Last Modified: 2014-03-05
I need to mark a column with a value...based on the length of data in another column.
Something like this....

UPDATE    myTable
SET              status = 'invalid'
WHERE     length(phone)<10

also....if the phone data contains text in the first 10 characters.
0
Comment
Question by:MikeCombe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39906709
Try something like:
UPDATE    myTable
    SET              status = 'invalid'
    WHERE     len(phone)<10
        OR ISNUMERIC(SUBSTRING(phone, 1, 10)) = 0

Open in new window

0
 

Author Closing Comment

by:MikeCombe
ID: 39906733
perfect. thanks !
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

752 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