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)
 search a word in a string

Author  Topic 

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2006-07-19 : 04:06:03
Hi

I have a string varchar variable @word and store in it this string "asde adsf afsdrh asjfktg ncdjft jfjgtkg kkglll" and want to search in this string a single word .How i can do it .
Please give me that solution which search a word and Time take minimum for search.


Ranjeet Kumar Singh

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-07-19 : 04:26:28
Somthing like this


Declare @Word Varchar

Set @Word = 'asde adsf afsdrh asjfktg ncdjft jfjgtkg kkglll'

if (@Word Like '%a%')
print 'Yes'
Else
print 'no'
-- Alternative Method.
if (CharINdex(@Word,'%a%')>0)
print 'yes'
else
print 'no'


Chirag
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-07-19 : 06:17:29
You might also want to look into full text searching functionality...

http://www.sqlteam.com/item.asp?ItemID=114
http://www.databasejournal.com/features/mssql/article.php/3441981


Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -