Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,
how to call a sqlfunction in storedprocedure using Sqlserver 2008?





Thanks&Regards
Hari
Posted
Updated 11-Sep-12 21:23pm
v2

HI ..

Please find details in below.
SQL
--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)
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 12-Sep-12 5:58am    
Thanq Arul
Arul R Ece 12-Sep-12 6:21am    
If it is help for you means accept this as answer
Hari Krishna Prasad Inakoti 12-Sep-12 6:41am    
ok.i'll try ur code after that i'll mark ur answer if it is working.
Hi,

Please try like below ,

SQL
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
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 12-Sep-12 3:29am    
if we using like ur format values are update in table?
Arul R Ece 12-Sep-12 4:32am    
Hey ,
This is just example foramt pa....
Hari Krishna Prasad Inakoti 12-Sep-12 5:57am    
itz ok...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900