LIKE without using dinamic sql

Last Post 07 Nov 2011 07:27 AM by dbandee. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
dbandee
New Member
New Member

--
19 Jan 2011 07:51 AM
is there way to pass multiple values to LIKE using variable without using dinamic sql?
for example i want to do




gunneyk
New Member
New Member

--
19 Jan 2011 09:54 AM
You forgot to post the example.
Vikrant More
New Member
New Member

--
19 Oct 2011 12:42 PM
yes it is possible you can use "[]" this brackets
say suppose if you pass in like '[a-b]' it will gives you all the results starting from a & b.
see the following examples,

--drop table #temp
create table #temp
(
id int identity(1,1)
,AccountNumber varchar(20)
)

insert into #temp values ('ada')
insert into #temp values('ada9')
insert into #temp values('adl')
insert into #temp values('agu')
insert into #temp values('ali')
insert into #temp values('alm')
insert into #temp values ('bag')
insert into #temp values('bai')
insert into #temp values('bai7')
insert into #temp values('bai8')
insert into #temp values('col')
insert into #temp values('dat')

select * from #temp where AccountNumber like '[a-b]%'

I think this way you want right ?

dbandee
New Member
New Member

--
07 Nov 2011 07:27 AM
thanks i figured it out
You are not authorized to post a reply.

Acceptable Use Policy