use xland
if not exists(select id from mytable)
    print '没?有?检?索?到?数?据?'
else
    begin
        select id from mytable
        print cast(@@rowcount as varchar)+'行?被?检?索?到?'
    end我在查询分析器里输入上面代码,运行结果是很多的id而没有print cast(@@rowcount as varchar)+'行?被?检?索?到?'
请问怎么样才能print cast(@@rowcount as varchar)+'行?被?检?索?到?'
谢谢

解决方案 »

  1.   


    use xland
    declare @id int
    set @id = 3
    if not exists(select 1 from mytable where id = @id)
      print '没?有?检?索?到?数?据?'
    else
      begin
      select * from mytable where id = @id
      print cast(@@rowcount as varchar)+'行?被?检?索?到?'
      end
      

  2.   

    if not exists(select id from mytable)
      select '没?有?检?索?到?数?据?'
    else
      begin
      select id from mytable
      select cast(@@rowcount as varchar)+'行?被?检?索?到?'
      end ??
      

  3.   


    use xland
    declare @id int
    declare @re varchar(10)
    set @id = 3
    if not exists(select 1 from mytable where id = @id)
      print '没?有?检?索?到?数?据?'
    else
      begin
      select * from mytable where id = @id
      select @re = ltrim(@@rowcount)
      print @re+'行?被?检?索?到?'
      end
      

  4.   

    查询-->将结果保存到-->以文本格式显示结果