日期:2014-05-18 浏览次数:20599 次
USE tempdb; GO IF OBJECT_ID('a') IS NOT NULL DROP TABLE a; GO --创建表a CREATE TABLE a (a1 INT , a2 INT ); GO --插入数据 INSERT INTO a VALUES (1,1); INSERT INTO a VALUES (2,2); INSERT INTO a VALUES (3,3); INSERT INTO a VALUES (4,4); INSERT INTO a VALUES (5,5); GO IF OBJECT_ID('spa') IS NOT NULL DROP PROCEDURE spa; GO --创建spa过程 CREATE PROCEDURE spa @a1 INT OUTPUT , @a2 INT OUTPUT AS BEGIN SELECT @a1=a1,@a2=a2 FROM a; END; GO --调用过程 DECLARE @a1 INT , @a2 INT EXEC spa @a1 OUTPUT ,@a2 OUTPUT ; SELECT @a1,@a2; --结果显示 (无列名) (无列名) 5 5
IF OBJECT_ID('spa') IS NOT NULL DROP PROCEDURE spa; GO --创建spa过程 CREATE PROCEDURE spa AS BEGIN SELECT a1,a2 FROM a; END; exec spa
------解决方案--------------------
你的两个输出参数@a1,@a2都是int 类型,而你想返回一个结果集,有点矛盾哦
------解决方案--------------------