Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Full-Text Search / August 2008

Tip: Looking for answers? Try searching our database.

Dealing with NULL in Contains

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
D. Andersen - 13 Aug 2008 06:46 GMT
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.
Russell Fields - 13 Aug 2008 20:17 GMT
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

> 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
[quoted text clipped - 24 lines]
>
> Any ideas?  I'd rather avoid messing with the variable in RS if possible.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.