• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1261
  • Last Modified:

Can we execute user defined function inside stored procedure in ms sql server?

Can we execute user defined function inside stored procedure in ms SQL server?

if yes, can u give a example? Is there any adverse effect ?
0
Tapan Pattanaik
Asked:
Tapan Pattanaik
  • 2
  • 2
  • 2
2 Solutions
 
Patrick MatthewsCommented:
You do not execute a UDF; you use it in expressions, including within queries, views, and sprocs.

As for adverse effects, compared to native SQL, UDFs run much slower, so if you can get the same result
using native SQL, you will get better performance.
0
 
BrandonGalderisiCommented:
There are two types of UDFs.  Scalar and Table valued.


The example of a scalar valued function would be.


select dbo.SomeFunction()

An example of a Table valued function would be.

select SomeValue from dbo.SomeFunction()


You can call it like any other SQL.
create procedure up_SomeProcedure 
as
 
select dbo.SomeFunction() as UDFValue

Open in new window

0
 
Tapan PattanaikSenior EngineerAuthor Commented:
Can we use user defined function inside stored procedure in ms sql server?

0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
Patrick MatthewsCommented:
tapanpattanaik,

As Brandon and I both stated above, yes.

Regards,

Patrick
0
 
Tapan PattanaikSenior EngineerAuthor Commented:
I am new to this subject, so i accept your comment as my solution
0
 
BrandonGalderisiCommented:
While you may not have gotten the answer you desired, it is 100% correct and a B is not an appropriate answer.  I would ask that you "request attention" and have the grade changed.  Request Attention can be found in your original post.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now