table变量 存储过程返回数据
CREATE PROCEDURE sp_getAllMT
AS
declare @tbl table(
mtid int,
mtname varchar(50),
orderid int
)
insert into @tbl values(0,'供应',0)
insert into @tbl select mtid,mtname,orderid from tbl_messagetype where mtid<50 order by orderid asc
insert into @tbl values(0,'求购',50)
insert into @tbl select mtid,mtname,orderid from tbl_messagetype where mtid>50 order by orderid asc
select * from @tbl
GO
--------------------------------------------------------------------
CREATE PROCEDURE sp_getAllMT
AS
select mtid,mtname,orderid from tbl_messagetype order by orderid asc
GO
----------------------------------------------------------------------
上面的两个存储过程返回的结果有什么不同?
我在程序中用set rs = conn.execute("sp_getAllMT")用第二个是正确的,第一个错误,提示"对象关闭时,不允许操作。",在查询分析器中两个存储过程都可以执行,返回预期的结果