SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Muliti value in like condition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sent_sara
Constraint Violating Yak Guru

India
366 Posts

Posted - 11/05/2013 :  16:58:20  Show Profile  Reply with Quote

Im trying to filter the word starts with SAG,WAG,DGA from the table:version of column versiondescription


tablename:version

versionid  versiondescription
********** *******************
1	    sag buildagreement
2	    wag buildagreement
3	    dga buildagreement



My existing query:

Declare @GuildFilter varchar(1000) 
declare @Guild varchar(1000)
set @Guild='DGA,WGA'
set @GuildFilter= '['+ replace(@Guild,',','-') +']%' 


SELECT * FROM version av
where av.versiondescription like '[DGA-WGA]%'



when i try to pass only DGA and WGA,query also picks SGA .can anyone help me out on this?



Bustaz Kool
Flowing Fount of Yak Knowledge

USA
1645 Posts

Posted - 11/05/2013 :  18:42:05  Show Profile  Reply with Quote
The brackets in a LIKE comparison act as special characters that enclose a set of characters to match. Your LIKE comparison is trying to find any string the begins with 'D' or 'G' or any letter between 'A' and 'W' or 'G' or 'A'. Lookup LIKE in Books Online.

HTH

=================================================
No, no, you're not thinking, you're just being logical. -Niels Bohr
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

India
366 Posts

Posted - 11/05/2013 :  21:47:58  Show Profile  Reply with Quote
I will be passing the parameter like either 'SAG' or 'Wga'or 'DGA'
OR ELSE all the three.based on this my like operator should work.
quote:
Originally posted by Bustaz Kool

The brackets in a LIKE comparison act as special characters that enclose a set of characters to match. Your LIKE comparison is trying to find any string the begins with 'D' or 'G' or any letter between 'A' and 'W' or 'G' or 'A'. Lookup LIKE in Books Online.

HTH

=================================================
No, no, you're not thinking, you're just being logical. -Niels Bohr


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000