Solved

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

Posted on 2014-03-05
2
188 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

624 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