我正在使用带有FileTable的SQL Server 2014 Express。我正在尝试从文件表(非结构化,pdf)中选择文件,具体取决于它们是否包含基于飞机注册标记的特定关键字:
--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))
没有SET @VARIABLE ='“”'我得到错误消息7645空或全空谓词。因此我在这个问题7645 Null or empty full-text predicate中添加了SET @VARIABLE ='“”'作为解决方案。但是,现在结果集是空的(没有找到文件),而我知道应该有结果。适当地设置变量,在该示例中分别为波音737和800。如果我将变量替换为字符串(例如'Boeing')作为CONTAINS中的参数,我确实得到了预期的结果。
任何人都知道问题是什么?除了使用SET @VARIABLE ='“”'避免错误之外,谷歌搜索了几个小时没有结果。
答案 0 :(得分:0)
好的,我最后通过将SET语句改为SET @variable =(SELECT ..)来修复它:
dataGridClients.DataSource = list;
无需SET @variable ='""'语句。