May 28, 2015 at 5:10 am
Okay - here is the problem I have.
We have a stock code table with a description field and a brand field - when the data was entered, some of the records were entered with the brand field in the description field.
ie.
Code Description Brand
ABC1 BLANK DVD SONY
ABC2 SONY BLANK DVD SONY
what I need to do is identify where the Brand is in the Description field ...
I have tried ;
select * from Table
where Description Like Brand
not very successful.
________________________________________________________________________________________________
Regards
Steve
SQL 2008 DBA/DBD - MCTS/MCITP
Please don't trust me, test the solutions I give you before using them.
May 28, 2015 at 5:47 am
SteveEClarke (5/28/2015)
Okay - here is the problem I have.We have a stock code table with a description field and a brand field - when the data was entered, some of the records were entered with the brand field in the description field.
ie.
Code Description Brand
ABC1 BLANK DVD SONY
ABC2 SONY BLANK DVD SONY
what I need to do is identify where the Brand is in the Description field ...
I have tried ;
select * from Table
where Description Like Brand
not very successful.
You're missing the wildcard characters on the front and back of the Brand you want to search for in Description.
select *
from Table
where Description Like '%' + Brand + '%';
This query is going to be slow because the leading % will prevent it from using an index, but it should find your offending rows. I'd suggest that you have the front end updated to not allow the bad data in there in the first place.
May 28, 2015 at 6:45 am
Thanks for your help.
Unfortunately the data is from old data - so this is the cleansing routines.
________________________________________________________________________________________________
Regards
Steve
SQL 2008 DBA/DBD - MCTS/MCITP
Please don't trust me, test the solutions I give you before using them.
May 28, 2015 at 7:21 am
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply