SQL Server 2008 query To Find Columns with incorrect information

20 pts.
Tags:
SQL data
SQL Database
SQL Query
SQL Server 2008
This is difficult to expalain so i will try and give you an example

Record                  Surname               Age            Town

1                          Smith                    50             SMITH AB

2                          Jones                     45             Leeds

3                          Patel                      38             PATEL AR

What someone has done is put in the wrong data in town name and instead used details that we put in a different field.

What i want to do is write a query that finds all the wrong ones. in this example it would pull off records 1 and 3

All the wrong records are in a format of SURNAME INITIALS Obviously it would be ideal if they were the same so i could put

where surname = town name,

But although they have part of the column the same it is not fully. Can someone advise the code i would need to use to find this, and if i need to define between capitals and lower too. Many Thanks



Software/Hardware used:
SQL Server 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.

How about something like this ?

<pre>SELECT *
FROM your_table
WHERE Town LIKE UPPER(Surname)+’%'</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following