本文介绍了如何使用sqlserver 2008在storageprocedure中调用sqlfunction?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
如何使用Sqlserver 2008在storageprocedure中调用sqlfunction?
谢谢与问候
Hari
Hi Friends,
how to call a sqlfunction in storedprocedure using Sqlserver 2008?
Thanks&Regards
Hari
推荐答案
--exec fun_proc 1,2
CREATE PROC fun_proc
@p_val1 int,
@p_val2 int
AS
BEGIN
Declare @sum int
select @sum = dbo.sums(@p_val1,@p_val2)--call function to get the value
print @sum
END
--Function
create function sums
(
@val int,
@val2 int
)
returns int
as
begin
return(@val + @val2)
end
select dbo.sums(1,2)
CREATE PROC fun_proc AS
BEGIN
declare @p_val1 int
Declare @@p_val2 int
select @p_val1 = object_id,@p_val2 = colid from sys.columns where object_name(object_id)= 'myTable'
declare @selVal as integer
set @selVal = select dbogetCalcvalue(@p_val1,@p_val2)--call function to get the value
END
这篇关于如何使用sqlserver 2008在storageprocedure中调用sqlfunction?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!