Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:09:54+00:00 2026-06-08T20:09:54+00:00

Yes, another SQL duplicates question :) I have a SQL Server 2008 R2 table

  • 0

Yes, another SQL duplicates question 🙂

I have a SQL Server 2008 R2 table with multiple phone number columns, looking something like:

ID   Tel1   Tel2   Tel3   Tel4   Tel5   Tel6
 1    123    456    789   NULL   NULL   NULL
 2    123    456    123    123   NULL   NULL
 3    456    789    123    456   NULL   NULL

I’d like to remove the duplicate phone numbers from each row – for example, in row ID 2, I need to NULL Tel3 and Tel4, and in row 3 I need to NULL Tel4. I don’t need to check for duplicates between rows – the same phone number can exist between in multiple rows, just not in different columns in the same row.

Can anyone suggest the best way to get rid of these duplicates?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:09:55+00:00Added an answer on June 8, 2026 at 8:09 pm

    Sql Fiddle here.

    update PhoneNumbers
       set Tel2 = case when Tel1 = Tel2 
                       then null 
                       else Tel2 end,
           Tel3 = case when Tel3 in (Tel1, Tel2) 
                       then null 
                       else Tel3 end,
           Tel4 = case when Tel4 in (Tel1, Tel2, Tel3) 
                       then null 
                       else Tel4 end,
           Tel5 = case when Tel5 in (Tel1, Tel2, Tel3, Tel4) 
                       then null 
                       else Tel5 end,
           Tel6 = case when Tel6 in (Tel1, Tel2, Tel3, Tel4, Tel5) 
                       then null 
                       else Tel6 end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in sql server 2008 R2. one table has records as
I have an SQL query that executes a LEFT JOIN on another table, then
In SQL server, I am trying to insert values from one table to another
I have a SQL Server that holds a lot of data. An application, running
I am using VS2005 C# and SQL Server 2005. I have a SQL Query
Itzik Ben-Gan explains in his book 'Inside Microsoft® SQL Server® 2008: T-SQL' how Appoach
I am using SQL Server 2008 Enterprise. And I am using Linked Server technologies
I am running Server Application on Windows Server 2008 with SQL Server 2008, Now
I have the following XML stored in an XML field in a SQL Server
In SQL Server, I have a stored procedure that accepts a date parameter. That

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.