查询不通过过程显示结果
query does not show result via procedure
我正在使用 sql 服务器 2005 数据库中的存储过程,该过程有一个查询
.
.
.
if(@zipCodeList <> '')
BEGIN
SET @zipCodeList = ''''+replace(replace(replace(@zipCodeList, ' ', ''),',',''','''),'_',' ')+''''
END
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN (@zipCodeList)
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions
.
.
.
像
一样调用程序
exec proc '02124, 23568'
数据库有记录,但程序没有显示任何内容,我打印了查询,它打印了
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN ('02124','23568')
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions
当我运行这个查询这个returns正确的结果。看起来 @zipCodeList
在 运行 时引起了一些问题,但没有给出任何错误,任何人都可以帮我解决我的错误。
提前致谢。
如果你的@zipCodeList 有像1,2,3
这样的值,那么执行下面的代码
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN
(
SELECT PARSENAME(REPLACE(Split.a.value('.', 'VARCHAR(500)'),'-','.'),1) 'Ids'
FROM
(
SELECT CAST ('<M>' + REPLACE(@zipCodeList, ',', '</M><M>') + '</M>' AS XML) AS Data
) AS A
CROSS APPLY Data.nodes ('/M') AS Split(a)
)
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions
我正在使用 sql 服务器 2005 数据库中的存储过程,该过程有一个查询
.
.
.
if(@zipCodeList <> '')
BEGIN
SET @zipCodeList = ''''+replace(replace(replace(@zipCodeList, ' ', ''),',',''','''),'_',' ')+''''
END
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN (@zipCodeList)
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions
.
.
.
像
一样调用程序exec proc '02124, 23568'
数据库有记录,但程序没有显示任何内容,我打印了查询,它打印了
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN ('02124','23568')
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions
当我运行这个查询这个returns正确的结果。看起来 @zipCodeList
在 运行 时引起了一些问题,但没有给出任何错误,任何人都可以帮我解决我的错误。
提前致谢。
如果你的@zipCodeList 有像1,2,3
这样的值,那么执行下面的代码
SELECT distinct ZIPCode
from zip_table
where ZIPCode_col IN
(
SELECT PARSENAME(REPLACE(Split.a.value('.', 'VARCHAR(500)'),'-','.'),1) 'Ids'
FROM
(
SELECT CAST ('<M>' + REPLACE(@zipCodeList, ',', '</M><M>') + '</M>' AS XML) AS Data
) AS A
CROSS APPLY Data.nodes ('/M') AS Split(a)
)
AND power((69.1 * (abs(Longitude) - abs(Longitude)) * cos(abs(Latitude)/57.3)),2) +
Power(69.1 * (abs(Latitude) - abs(Latitude)), 2) <= (60 * 60)
AND more conditions