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)
 problem with like opeartor

Author  Topic 

kirank
Yak Posting Veteran

58 Posts

Posted - 2010-08-16 : 06:54:57
hi if i run the 1st query it return 1 records
but if i run 2nd it shows 0 records, there is only one change i have done
simple replacing the string with the actual database columns
but still its not working i thing some prb with like ,
plz can u help me to identify it

thank you,

select * from Tbl E
WHERE LEN(LTRIM(RTRIM(E.[Brs]))) > 0
AND LTRIM(RTRIM(E.[brs])) not like
(SELECT top 1 Vctb FROM TblB WHERE Vcb like 'ABCD%' AND
INTBID IN (SELECT TOP 1 INTBID FROM TblB WHERE Vcb like 'TEST TEST TEST%')) +'%'


select * from Tbl E
WHERE LEN(LTRIM(RTRIM(E.[Brs]))) > 0 AND
LTRIM(RTRIM(E.[brs])) not like
(SELECT top 1 Vctb FROM TblB WHERE Vcb like Ltrim(E.[brs])+'%' AND
INTBID IN (SELECT TOP 1 INTBID FROM TblB WHERE Vcb like Ltrim(rtrim(E.[brs])) +'%')) +'%'

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-16 : 07:12:19
Syntactically it seems there is no problem, can you post some sample data ?

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -