当前位置: 代码迷 >> Sql Server >> 这个存储过程为什么读不出数据啊郁闷,该怎么解决
  详细解决方案

这个存储过程为什么读不出数据啊郁闷,该怎么解决

热度:82   发布时间:2016-04-27 17:49:08.0
这个存储过程为什么读不出数据啊?郁闷
CREATE   PROCEDURE   PrSerchTag  
@tag   varchar(20)
AS
declare   @id   int
declare   @tagid   int
--declare   @bool   char(4)
begin
  if   exists   (select     tagid   from   tagtable   where   tagname   like     '% '[email protected]+ '% ')
          begin
             
                      select   @tagid   =     tagid   from   tagtable   where   tagname   like       '% '[email protected]+ '% '
                select   @id=   rizhiid   from   rizhitagtable   where   tagid   [email protected]
                select   rizhiid,yonghuname,rizhititle,substring(rizhicontent,0,200)+ '...... '   as   'rizhicontent ',rizhitime,touchnum,yonghuid   from   rizhiview   where   [email protected]
        end
  else
                return   (0)


end

------解决方案--------------------
if exists (select tagid from tagtable where tagname like '% '[email protected]+ '% ')
begin

.....
-->


if exists (select tagid from tagtable where tagname like '% '[email protected]+ '% ')
begin

select 1 --加上这条,执行后看看有没有执行到这句。
.....
------解决方案--------------------
select @tagid = tagid from tagtable where tagname like '% '[email protected]+ '% '
select @id= rizhiid from rizhitagtable where tagid [email protected]

tagid应可能有多个值吧,[email protected]
rizhiid也有可能有多个值的,[email protected]
------解决方案--------------------
@tagid只能是最后的一个tagid的值
@id也只能是rizhiid的最后一个值
------解决方案--------------------
@tagid,@id 只读出一个值,建议楼主写成游标
------解决方案--------------------
similarly answer below:

HTTP://www.ebigear.com/Fund/PlayNews.php?NewsID=28340&ID=285885

  相关解决方案