We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

Medium Priority
1,277 Views
Last Modified: 2012-05-06
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 ?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
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

Tapan PattanaikSenior Engineer

Author

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

CERTIFIED EXPERT
Top Expert 2010

Commented:
tapanpattanaik,

As Brandon and I both stated above, yes.

Regards,

Patrick
Tapan PattanaikSenior Engineer

Author

Commented:
I am new to this subject, so i accept your comment as my solution
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.