Click here to Skip to main content
12,398,000 members (54,046 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL-Server
Can we call function from stored procedure in SQL Server?Give any examples.
Posted 19-Aug-12 20:47pm
Updated 28-Aug-12 20:16pm
v2
Comments
d@nish 20-Aug-12 2:49am
   
You could have used google or MSDN for this. Have you searched anything?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hello,

We can call user defined function from from the stored procedure.
like,

Select dbo.FunctionName(parameters of function) AS Function Return Value
From TableName

Function passing parameter should be in select statement.

Like,

Select A1, A2,A3, dbo.FunctionName(A1,A2) AS AValue From TableName

Thanks,
Viprat
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

yes
because,
store procedure consist of one or more sql queries
and In sql query we can call function so, alternately we can say that we can call function in store procedures

here is an example how to call function in sql query
e.g.
select getdate() --getdate() is sql-function

same way user-defined function can be called.
e.g
select dbo.fn_OnlyDate() --suppose, onlydate is user-defined sql function; (dbo is schema name because user defined function are accessed using schema name- just for your knowledge.)

Happy Coding!
Smile | :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hi,
The following statements are valid in a function:
Valid Operations in SQl-Functions:
Assignment statements.
Control-of-Flow statements except TRY...CATCH statements.
DECLARE statements defining local data variables and local cursors.
SELECT statements that contain select lists with expressions that assign values to local variables.
INSERT, UPDATE, and DELETE statements modifying local table variables.
EXECUTE statements calling extended stored procedures.



--Amit
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100