Solved

convert query to UDF

Posted on 2013-01-08
2
168 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 26

Accepted Solution

by:
Chris Luttrell earned 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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