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
 General SQL Server Forums
 New to SQL Server Programming
 charindex help

Author  Topic 

crsri
Starting Member

1 Post

Posted - 2009-08-26 : 19:22:01
Below is my query,

CHARINDEX(B.PHONEBUILD+'_',A.JOBNAME)>0

The above statement gives all the phonebuild which matches with jobname and have '_' in the jobname
eg results:

PhoneBuild Jobname
Q6270BKPRQL136022 Q6270BKPRQL136022_11JUL2009_002854am
Q6270BKPDZL136022 Q6270BKPDZL136022_11JUL2009_003046am

i am looking for the phonebuild which are exact match with jobname,
something like below

PhoneBuild Jobname
Q6270BKPRQL136022 Q6270BKPRQL136022
Q6270BKPDZL136018 Q6270BKPDZL136018

Please Help

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-26 : 23:13:39
[code]
select *
from yourtable
where PhoneBuild = left(Jobname, len(PhoneBuild))
[/code]


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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-27 : 01:41:46
select *
from yourtable
where Jobname like PhoneBuild+'%'




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-08-27 : 02:10:49
You can try sub string too

select *
from yourtable
where PhoneBuild = substring( Jobname,0,charindex('_', Jobname))

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -