I'm working with SQL Server 2014 Express with FileTable. I'm trying to select documents from the filetable (unstructured, pdf) based on whether they contain specific keywords based on the registration mark of an aircraft:
--SET VARIABLE FOR A REGISTRATION MARK
DECLARE @Reg nvarchar(10)
SET @Reg = 'PH-BGA'
--SET VARIABLE FOR MANUFACTURER OF REGISTRATION MARK
DECLARE @Manufacturer nvarchar(10) = NULL
SELECT FleetInfoKLM.Manufacturer FROM FleetInfoKLM WHERE FleetInfoKLM.Reg = @Reg;
SET @Manufacturer = '""'
--SET VARIABLE FOR FAMILY OF REGISTRATION MARK
DECLARE @Family nvarchar(10) = NULL
SELECT FleetInfoKLM.Family FROM FleetInfoKLM WHERE FleetInfoKLM.Reg = @Reg;
SET @Family = '""'
--SET VARIABLE FOR SERIES OF REGISTRATION MARK
DECLARE @Series nvarchar(10) = NULL
SELECT FleetInfoKLM.Series FROM FleetInfoKLM WHERE FleetInfoKLM.Reg = @Reg;
SET @Series = '""'
--SELECT MAINTENANCE DOCUMENTS BASED ON VARIABLES FOR MANUFACTURER, FAMILY AND SERIES
SELECT MaintenanceDocumentation.name FROM MaintenanceDocumentation
WHERE ((@Manufacturer = '""') AND CONTAINS(file_stream, @Manufacturer))
AND ((@Family = '""') AND CONTAINS(file_stream, @Family))
AND ((@Series = '""') AND CONTAINS(file_stream, @Series))
Without SET @VARIABLE = '""' I get the error Msg 7645 Null or empty full-text predicate. Hence I added the SET @VARIABLE = '""' as it was found as a solution in this question 7645 Null or empty full-text predicate. However, now the result set is empty (no documents found), while I know that there should be results. The variables are properly set, in this example as Boeing, 737 and 800 respectively. If I replace the variables as a string (e.g. 'Boeing') as an argument in CONTAINS, I do get the expected results.
Anyone got a clue what the problem is? Have been Googling for hours without result other than avoiding the error with SET @VARIABLE = '""'.