Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server Homework
Can we call function from stored procedure in SQL Server?Give any examples.
Posted 19-Aug-12 21:47pm
Edited 28-Aug-12 21:16pm
v2
Comments
d@nish at 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
0 OriginalGriff 370
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 235
3 Afzaal Ahmad Zeeshan 209
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2014
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