还没解决完搜索存储过程
存储过程为:
ALTER proc test1
@sale_name varchar(50),
@quyu varchar(50),
@subxingzhi_name varchar(50),
@developer_name varchar(50),
@room_type int,
@chaoxiang varchar(50),
@area float,
@price float,
@sql varchar(8000) output
as
set @sql= 'select distinct * from sale
a,householdmodel b,developers c ,subxingzhi d
where a.sale_id=b.sale_id and a.developer_id=c.developer_id and a.subxingzhi_id=d.subxingzhi_id '
if @sale_name <> '1 '
begin
set @sql=@sql+ ' and a.sale_name= ' ' '+@sale_name+ ' ' ' '
end
if @quyu <> '1 '
begin
set @sql=@sql+ ' and a.quyu= ' ' '+@quyu+ ' ' ' '
end
if @subxingzhi_name <> '1 '
begin
set @sql=@sql+ ' and d.subxingzhi_name= ' ' '+@subxingzhi_name+ ' ' ' '
end
if @developer_name <> '1 '
begin
set @sql=@sql+ ' and c.developer_name= ' ' '+@developer_name+ ' ' ' '
end
if @room_type <> '1 '
begin
set @sql=@sql+ ' and b.room_type= '+cast(@room_type as varchar)
end
if @chaoxiang <> '1 '
begin
set @sql=@sql+ ' and b.chaoxiang= ' ' '+@chaoxiang+ ' ' ' '
end
if @area <> '1 '
begin
set @sql=@sql+ ' and a.area= '+cast(@area as varchar)
end
if @price <> '1 '
begin
set @sql=@sql+ ' and a.price= '+cast(@price as varchar)
end
print @sql
exec (@sql)
执行为:
exec test1 'aa ', 'b ', '1 ', '1 ', '1 ', '1 ', '1 ', '1 ',2
为什么返回的为空呢?
aa 和b 表中都的数据
------解决方案--------------------在你的消息那看看在结果是看不到的