Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello buddy ........

Thanks of all.......




I am use a stored procedure , in this sp i am call a another sp or another function
these will return a value , My Query is which one better in sp or function.
Any one tell me a powerful region.

As like.........


Create proc testProcedure
as

exec anotherProcedure -- It is return a value ---No1

SELECT dbo. anotherFunction (@Parameter) -- Itis return a value---No2



so which one is better use both of them.


Thanks.

sanwar
Posted
Comments
StianSandberg 18-Jul-12 8:53am    
Functions are in general slower.. I never use functions in my sql. And to use a function to do querying is no-go..
sanwar_mal_jat 18-Jul-12 9:28am    
plz tell me any logically region can why slower function

1 solution

function and stored procedure both are stored in compiled format in database.

SQL
SELECT dbo. anotherFunction (@Parameter)


Above statement is better if u need only select statement in function/procedure,because can not execute any other statement.
function can call from any statement.
like
SQL
select anotherFunction(@parameter)

above statement is possible

SQL
select anotherstoredprocedure

above statement is not possible.
 
Share this answer
 
Comments
sanwar_mal_jat 18-Jul-12 9:29am    
ya but which one is better (SP or Function)
Kaushik Saha from Kolkata,India 18-Jul-12 9:45am    
function is better as per your question.Because you can use in inline.

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