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 2005 Forums
 Transact-SQL (2005)
 Inner join and string

Author  Topic 

lovehui
Yak Posting Veteran

60 Posts

Posted - 2009-03-27 : 14:43:39
Suppose I have two tables A and B.
There are no common fields except the following

Table A

US Dollar
Check


Table B


US Dollar Reason
Check Reason

May I join them by manipulating strings?

Thanks

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-27 : 14:54:20
you can.
Go to Top of Page

lovehui
Yak Posting Veteran

60 Posts

Posted - 2009-03-27 : 14:55:49
But I don't know how?
Can anyone contribute a piece of code?
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-27 : 15:00:43
[code]Go
create table #TableA (col1 varchar(100))
Go
insert into #TableA
select 'US Dollar' union all
select 'Check'
Go
create table #TableB (col1 varchar(100))
Go
insert into #TableB
select 'US Dollar Reason' union all
select 'Check Reason'


select
*
from
#TableA a
join #Tableb b on a.col1=replace(b.col1,'Reason','')[/code]
Go to Top of Page
   

- Advertisement -