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)
 NEED QUERY

Author  Topic 

niranjankumark
Posting Yak Master

164 Posts

Posted - 2008-01-26 : 04:13:32
my 2 table has data

table1
========
001
002
003
004
005
006
007
table2
========
0001
002
003
0004
005
008

need output as
===============
001 0001
004 0004

note : 002, 003 are same but not need. differes in zero alone.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-26 : 04:31:11
what is the relationship between table1 and table2 ?

How do you relate Table1's 001 to Table2's 0001 and 004 to 0004 ?

How about 006 and 007 of Table1 and What happen to 008 of table2 ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

niranjankumark
Posting Yak Master

164 Posts

Posted - 2008-01-26 : 04:40:00
Consider starting value is zero. in both table column
i shud remove zero only if it differs,
ex : 001 & 0001
filter the zero in this condition and match.
But suppose
ex : 002 & 002 i shud not filter zero.becouse zero count are same. it is not required.Key point is filter zero if it deiiffer, if other valu differ mean not required like 008.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-26 : 11:12:51
Try:-

SELECT t1.Col as Col1,t2.Col as Col2
FROM table1 t1
INNER JOIN table2 t2
ON t2.Col<>t1.Col
AND RIGHT(t2.Col,LEN(t1.Col))=t1.Col
Go to Top of Page
   

- Advertisement -