Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 不需要查询结果_Sql Server_Sql Server 2005_Coldfusion - Fatal编程技术网

Sql server 不需要查询结果

Sql server 不需要查询结果,sql-server,sql-server-2005,coldfusion,Sql Server,Sql Server 2005,Coldfusion,我已经做了15年的CF开发人员,我从未遇到过如此奇怪或令人沮丧的事情。我把头发拔了好几个小时,在谷歌上搜索,抽象,简化,祈祷,然后反过来做。你能帮我吗 cffunction接受一个字符串参数,并从该字符串构建一个“短语”数组来运行查询,试图匹配数据库中的位置名称。例如,字符串“the republic of boulder”将生成数组:[“the”、“republic”、“of”、“boulder”、“the republic”、“the republic of”、“the republic o

我已经做了15年的CF开发人员,我从未遇到过如此奇怪或令人沮丧的事情。我把头发拔了好几个小时,在谷歌上搜索,抽象,简化,祈祷,然后反过来做。你能帮我吗

cffunction接受一个字符串参数,并从该字符串构建一个“短语”数组来运行查询,试图匹配数据库中的位置名称。例如,字符串“the republic of boulder”将生成数组:[“the”、“republic”、“of”、“boulder”、“the republic”、“the republic of”、“the republic of boulder”、“republic of”、“the republic of boulder”、“of boulder”]

另一个cffunction使用前面提到的cffunction并运行cfquery。基于前面给出的示例的查询将是

从vwLocationsWithAlias中选择locationid、locationname、locationaliasname,其中locationname位于('the'、'the republic'、'the republic'、'republic'、'republic of'、'republic of'、'republic of'、'boulder')或locationaliasname中(‘共和国’、‘共和国’、‘共和国’、‘共和国’、‘博尔德共和国’、‘共和国’、‘博尔德’、‘博尔德’、‘博尔德’)

这将返回2条记录

locationid-locationname-locationalias

99-“博尔德”-“共和国”

68-‘圆石’-空

这很好。效果很好。但是…如果字符串更改为“the republic”,则会产生短语数组[“the”,“republic”,“the republic”],然后用于生成查询

从vwLocationsWithAlias中选择locationid、locationname、locationaliasname,其中locationname位于('the','the republic','republic')或locationaliasname位于('the','the republic','republic'))

这将返回0条记录。说什么?!好吧,为了确保我没有不由自主地兴奋,我在SQL控制台中对cf数据源中的同一数据库运行了相同的查询。1条记录

locationid-locationname-locationalias

99-“博尔德”-“共和国”

我甚至可以在同一个cffunction中硬编码该sql,并获得一个结果,但决不能从动态生成的sql中获取。我可以从另一个不同名称的cffunction中获取位置短语,该函数返回硬编码的数组值和这些值,但如果数组是动态构建的,则决不能。我已经尝试删除cfqueryparams,triple ch查看我的数据类型、数据源设置等,等等。没有骰子

WTF!?这是一个晦涩难懂的错误吗?我疯了吗?我已经尝试了我能想到的一切,其他人(包括雷·卡姆登)也能想到的一切

ColdFusion 8(具有所有最新的修补程序) SQL Server 2005(具有所有最优秀的service Pack)
Windows 2003服务器(具有所有最新更新、服务包和每晚MS voodoo)

在我看来,您的函数生成的查询与预期的略有不同,请在生成查询后尝试在函数中设置断点,复制生成的查询并在sql server中运行。我希望也不会找到任何结果


可能是一些空格或导致找不到记录的内容。注意:您正在搜索精确的字符串。要搜索近的字符串,请在查询中使用。

您使用的是CF 8还是CF 8.01?如果您尚未使用,请升级到CF 8.01


您也可以尝试为SQL Server 2005加载与内置JDBC驱动程序不同的JDBC驱动程序。请参阅我的建议,因为CF/JRUN和数据库之间的连接似乎是您出现问题的层。这篇文章有点旧,因此它可能没有指向SQL Server 05的最新JDBC驱动程序。否。我已转储了查询并在运行后立即中止。感谢playing.OMG。我觉得自己太愚蠢了。我花了大概10个小时来查找这个,是的……生成短语列表的函数中有一个多余的空格。我没有看到它或复制它,因为浏览器忽略了连续空格,只输出一个空格。毕竟,你赢了!