Solved

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

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

763 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