遇到的最难的存储过程嵌套游标问题,高手请进!!!
创建一个存储过程 P3,列出Northwind库中的products表中UnitsOnOrder最高的五种商品的相关信息。(用游标做)
------解决方案--------------------select top 5 UnitsOnOrder, *
from products
order by UnitsOnOrder desc
------解决方案----------------------用top 5,如下
select top 5 UnitsOnOrder, *
from products
order by UnitsOnOrder desc
--或者如下:
set rowcount 5
select UnitsOnOrder, *
from products
order by UnitsOnOrder desc
------解决方案----------------------能用一条SQL实现的,为什么要用游标,舍近求远?
--用top 5,如下
select top 5 UnitsOnOrder, *
from products
order by UnitsOnOrder desc
--或者如下:
set rowcount 5
select UnitsOnOrder, *
from products
order by UnitsOnOrder desc