Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Match values between 2 fields

Author  Topic 

gova
Starting Member

1 Post

Posted - 2008-10-20 : 15:55:51
Is there a possibility to extract some characters from a field to match with another field? following is an example:

a field containing this value 'Whooper Swan' to match it with another field containing this value 'Whopper Swan'. Had no luck with the wildcards so far.

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-20 : 18:11:43
Something like:
declare @tab1 table (id bigint identity(1,1), col1 varchar(100), col2 varchar(100))

insert into @tab1
select 'I am Whooper Swan Jr.', 'and my father is Whooper Swan Sr.' union all
select 'I am Hooper Swanson', 'and my father is Whooper Swanson Sr.' union all
select 'I am Whooper Seewan Jr.', 'and my father is Whooper Swan Sr.' union all
select 'I am Whoper Swan Jr.', 'and my father is Whooper Swan Sr.'

select * from @tab1
where col1 like '%Whooper Swan%' and col2 like '%Whooper Swan%'


id col1 col2
-------------------- -------------------------------------------------- --------------------------------------------------
1 I am Whooper Swan Jr. and my father is Whooper Swan Sr.

(1 row(s) affected)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-21 : 00:22:50
i think what you need is DIFFERENCE function.

http://doc.ddart.net/mssql/sql70/de-dz_7.htm
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-21 : 10:15:18
seriously! i can't tell the diff between Whooper and Whopper ....
Go to Top of Page
   

- Advertisement -