Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

convert query to UDF

Posted on 2013-01-08
2
Medium Priority
?
174 Views
Last Modified: 2013-01-09
I received help here in EE to write a query that is working well for my desired results.

I now need to convert the query into a UDF or stored procedure that returns the table results that the query currently produces.

I need help figuring out how to convert the query to a UDF. I do not know how to replace the ;WITH  part of the code when inside a function.


Thank you much.
ee-sql-script.txt
0
Comment
Question by:metropia
2 Comments
 
LVL 27

Accepted Solution

by:
Chris Luttrell earned 2000 total points
ID: 38757855
just wrap your code with something like this:
CREATE PROCEDURE yourProcName
AS
BEGIN
-- all your code here
END

Open in new window

and then when you call it like this it will return the same thing you are getting from the query.
EXEC yourProcName

Open in new window

0
 

Author Comment

by:metropia
ID: 38759152
thank you. I was trying to put all the code in a user defined function instead that a stored procedure, and I was getting errors on the line containing the ;WITH
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question