1. 使用存储过程的参数的OUTPUT选项
2. 如果是2000,可以考虑自定义函数。
解决方案 »
- 几万个字的文本如何写到SQL数据库里?
- 一个比较难的SQL,帮忙看看怎么得出来!
- 帮我看一下有什么错误啊,怎么得不到想要是结果啊
- 考虑系统维护中的基础数据、关键业务数据维护加强控制,记录维护用户名、维护时间(增、删、改均需记录)
- SQL自连接查询,为什么下面两句的查询结果不一样? ############# 100% j结贴
- 将EXCEL表中的数据导入到SQL Server 2005中
- 一条超难解决的sql语句
- 取表的字段名,字段类型,字段长度
- Sql Server 中序列的实现
- How to convert Access to Oracle Database?Help!
- 那有erwin的中文书下阿?
- 问一下各位老大,为什么存储过程传不出返回值
CREATE PROCEDURE get_sales_for_title
@title varchar(80), -- This is the input parameter.
@ytd_sales int OUTPUT -- This is the output parameter.
AS
-- Get the sales for the specified title and
-- assign it to the output parameter.
SELECT @ytd_sales = ytd_sales
FROM titles
WHERE title = @title
RETURN
GO
-- Declare the variable to receive the output value of the procedure.
DECLARE @ytd_sales_for_title int
-- Execute the procedure with a title_id value
-- and save the output value in a variable.
EXECUTE get_sales_for_title "Sushi, Anyone?", @ytd_sales = @ytd_sales_for_title OUTPUT
-- Display the value returned by the procedure.
PRINT 'Sales for "Sushi, Anyone?": ' + convert(varchar(6),@ytd_sales_for_title)
GO
EXECUTE get_sales_for_title "Sushi, Anyone“
FETCH get_sales_for_title into @ytd_sales_for_title
@ytd_sales_for_title前用不用加:号,如果不对,请提示正确的写法?
谢谢!
中的@ytd_sales = @ytd_sales_for_title 的顺序对吗?
怎样解释?
”请都如果自定义函数?”什么意思?
@ytd_sales 变量在存储过程主体中包含参数值,而该存储过程在退出时,将 @ytd_sales 变量值返回至调用程序。这常常被称作"传址调用功能"。
在联机帮助中有很详细的解释,建议去看看,这个是上面的例子。