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
 SQL Server Development (2000)
 HOW to use ESCAPE character in LIKE operator for string search

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-13 : 01:48:42
subhas writes "hi,
I want a simple code.
I want a code to use escape charecter in string search using like operation.
I have a procedure where there is a input parameter @proteinname.
in the proc, i issue a SQL command like this:

select * from <TABLE where protein_name like ' '
I want to escape "@" so that it takes only the value and not @

pls help me..i need it urgently"

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-05-13 : 02:27:47
subhas, don't really understand what you want...

maybe?
select * from <TABLENAME> where protein_name like <BLA> escape '@'

??

Maybe you could post some example data and the proc code...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

rksingh024
Yak Posting Veteran

56 Posts

Posted - 2002-05-13 : 06:16:10
May be you want something like this

----------
create table #tmp(e_name varchar(20))

insert into #tmp values ('RK-s')
insert into #tmp values ('RK-s2')
insert into #tmp values ('K-s')
insert into #tmp values ('K-s@1')
insert into #tmp values ('RK-1s')
insert into #tmp values ('R%-s@')

select * from #tmp where e_name like '%[%]%'

drop table #tmp
----------

Ramesh

Go to Top of Page
   

- Advertisement -