SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Full Text Search Wildcards


Full Text Search Wildcards

Author
Message
Doug Andersen
Doug Andersen
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 130
I'm trying to figure out a wildcard string that will bring back essentially all results in full-text search, I'm thinking something like [a-z]*.

Why?

Because it's tied to a reporting services report with several optional parameters, including name. So if the name isn't used as a parameter (it's left null) then I need to substitute a wildcard that won't limit the search in that regard (and just limit on the other parameters).

As in...

select *
from table
where country in (@countryparameter)
and customertype in (@customertypeparameter)
and contains(name,'*')
Jerry Hung
Jerry Hung
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3552 Visits: 1208

select *
from table
where country in (@countryparameter)
and customertype in (@customertypeparameter)
and (@name IS NULL OR contains(name,@name))


would this work?

SQLServerNewbie

MCITP: Database Administrator SQL Server 2005
Doug Andersen
Doug Andersen
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 130
Nope, because full-text searches complain when you attempt to search with a null.
Jerry Hung
Jerry Hung
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3552 Visits: 1208
Doug Andersen (9/23/2008)
Nope, because full-text searches complain when you attempt to search with a null.


Yes, the stupid NULL predicate

But maybe a clever getaround?
Hopefully the short circuit will pick up the first condition (@name = 'nothing') without calling CONTAINS
You never know with SQL full-text functions Tongue



IF @name IS NULL
SET @name = 'nothing'

select *
from table
where country in (@countryparameter)
and customertype in (@customertypeparameter)
and (@name = 'nothing' OR contains(name,@name))



SQLServerNewbie

MCITP: Database Administrator SQL Server 2005
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search