Solved

convert query to UDF

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query 34 82
SQL Server - SQL field is defined as text 3 32
mysql joining from the same table 6 37
Anyway to make these 2 SQL statements into one? 13 27
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now