能不能从一个存储过程返回一个值,供另一个存储过程使用?

scutcs 2006-04-08 06:40:07
我想从一张成绩单中,根据成绩高低确定等级1,2,3,4等.

然后返回这个等级供另一个存储过程来计算积点. 能不能实现?
...全文
110 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xeqtr1982 2006-04-08
  • 打赏
  • 举报
回复
set nocount on
create table t([id] int,[name] varchar(10))
insert into t select 1,'song'
insert into t select 2,'xs'
insert into t select 3,'ttw'
go

create proc tt
@name varchar(10),
@id int OUTPUT
as

select @id=id from t where [name]=@name
return
go

create proc tt1
@id int
as

print @id
go

declare @id int
exec tt 'song',@id OUTPUT
exec tt1 @id
go

drop proc tt
drop proc tt1
drop table t
xeqtr1982 2006-04-08
  • 打赏
  • 举报
回复
set nocount on
create table t([id] int,[name] varchar(10))
insert into t select 1,'song'
insert into t select 2,'xs'
insert into t select 3,'ttw'
go

create proc tt
@name varchar(10),
@id int OUTPUT
as

select @id=id from t where [name]=@name
return
go

create proc tt1
as

declare @id int
exec tt 'song',@id OUTPUT
print @id
go


exec tt1

drop proc tt
drop proc tt1
drop table t
擒兽 2006-04-08
  • 打赏
  • 举报
回复
WEB里面容易,不知道查询分析器或存储过程本身如何获取返回值,再以变量的形式exec另外一个过程
擒兽 2006-04-08
  • 打赏
  • 举报
回复
mark
scutcs 2006-04-08
  • 打赏
  • 举报
回复
谁能给我举一例:
定义两个简单的存储过程A,B
其中A返回一个变量a
然后B以这个a为参数被调用.

我就结帖.
scutcs 2006-04-08
  • 打赏
  • 举报
回复
楼上回答太简练了吧. 给我两句伪代码也好
xeqtr1982 2006-04-08
  • 打赏
  • 举报
回复
可以

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧