首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请各位大侠看看。解决办法

2012-05-02 
请各位大侠看看。。。。。。。。。。。11.查询是否所有的玩具都曾经被人订购,如果是的话,那么打印消息‘All Toys have

请各位大侠看看。。。。。。。。。。。
11.查询是否所有的玩具都曾经被人订购,如果是的话,
那么打印消息‘All Toys have ever been ordered’。
否则,打印消息‘Some kind of toys are not so popular ’,
并列出没有被人订购过的玩具的详细信息。
   
  if exists (select cToyId from OrderDetail where cToyId !=ALL (select cToyId from Toys) )
  print 'All Toys have ever been ordered' 
  else
  begin
  print 'Some kind of toys are not so popular '
  select * from Toys where cToyId not in(select cToyId from OrderDetail )
  end

运行结果: 只是显示没有被人订购过的玩具的详细信息的表,
  为什么没有打印'Some kind of toys are not so popular '?


[解决办法]
因为打印的信息在“消息”选项卡里面,不在“结果”选项卡里面
[解决办法]
lz:基于你的问题的解答:

print :这个是输出到输出窗口

select :这个是输出到查询窗口

把你的print换成select就行了。你就可以看到他们了,但这还不在同一个窗格内,不过你可以看到了。

希望楼主成功。

热点排行
Bad Request.