Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Dealing with NULL in Contains

 
   Database Forums (Home) -> Full Text RSS
Next:  un Achat de acomplia us usa avec livraison PERTE ..  
Author Message
D. Andersen

External


Since: Aug 12, 2008
Posts: 1



(Msg. 1) Posted: Tue Aug 12, 2008 10:46 pm
Post subject: Dealing with NULL in Contains
Archived from groups: microsoft>public>sqlserver>fulltext (more info?)

I'm using a Contains clause for some data that's getting passed from
Reporting Services and I'm having trouble dealing with NULL, which creates a
"Null or empty full-text predicate." error.

My first thought was to trap it using a coalesce or isnull as in
contains(companynamecolumn,isnull(@report_parameter,'thiswillneverbefound'))

but that didn't work. I also tried using a case within the contains, also
didn't work.

I also tried using the OR as in

contains(companyname,'@report_parameter OR "thiswillneverbefound"')

but it took the "report_parameter" literally and even if I missed with the
string literal to fix it I'm guessing it will still choke on the NULL.

The only other idea I had was to use a case before the contains as in

case when @report_parameter is not null then
contains(companyname,@report_parameter) else contains(companyname,'adfdas')
end

but that's not going to fly.

Any ideas? I'd rather avoid messing with the variable in RS if possible.

 >> Stay informed about: Dealing with NULL in Contains 
Back to top
Login to vote
Russell Fields

External


Since: Feb 21, 2007
Posts: 457



(Msg. 2) Posted: Wed Aug 13, 2008 3:17 pm
Post subject: Re: Dealing with NULL in Contains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

D.

Trap the problem before making your fulltext query. E.g.

SET @report_parameter = isnull(@report_parameter,'thiswillneverbefound')

Then your code would simply use:

contains(companyname,@report_parameter)

RLF

"D. Andersen" wrote in message

> I'm using a Contains clause for some data that's getting passed from
> Reporting Services and I'm having trouble dealing with NULL, which creates
> a
> "Null or empty full-text predicate." error.
>
> My first thought was to trap it using a coalesce or isnull as in
> contains(companynamecolumn,isnull(@report_parameter,'thiswillneverbefound'))
>
> but that didn't work. I also tried using a case within the contains, also
> didn't work.
>
> I also tried using the OR as in
>
> contains(companyname,'@report_parameter OR "thiswillneverbefound"')
>
> but it took the "report_parameter" literally and even if I missed with the
> string literal to fix it I'm guessing it will still choke on the NULL.
>
> The only other idea I had was to use a case before the contains as in
>
> case when @report_parameter is not null then
> contains(companyname,@report_parameter) else
> contains(companyname,'adfdas')
> end
>
> but that's not going to fly.
>
> Any ideas? I'd rather avoid messing with the variable in RS if possible.

 >> Stay informed about: Dealing with NULL in Contains 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
help to define a search criteria with FTS - Hi! I'm using FTS in MSSQL2000. 1. i have a string "bcd" and i want the results : "abcd" or "1bcd" but not "bcda" or "aabcd" (always from the second letter). 2. the search column is a long string. the ...

CONTAINSTABLE - weird results - using "and not" - Hello everyone, I use full text search using containstable for search on my intranet site. Its been working wonderfully. However, I have recently been working on an upgrade to my search page to allow users to exclude words. When excluding words I use...

How to pass an SQLServer object to a method - Hi, I am writing some code in VB.NET and need to pass an SQLServer object to a method. How do I do that? What is the type of SQLServer object? I created it using : Dim oSQLServer = CreateObject("SQLDMO.SQLServer") and want to pass it to a ...

Rebuilding Full Text Catalog - Hi, I have created a db install app that will install all datatables, build full-text catalogs and add job scheduler to populate the catalogs several times a day. However, I would also like my catalogs to be rebuilt every midnight and repopulated again...

incremental population vs. change tracking - We are developing a Content Management System using both SQL Server 2000 and file system as repository. The files (content) are stored on disk and addition properties are stored in an SQL Server database. We'd like to provide Search functionality on..
   Database Forums (Home) -> Full Text All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]