Solved

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

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL replication over high latency link 10 59
TSQL Challenge... 7 35
SSAS Store Forecasting data in the cube 1 17
MS SQL SERVER and ADODB.commands 8 20
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

856 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