Contains function in request?

I have a query for a test database that relies on a function installed in that database. I need to run this request on another server that does not have this function and on which I cannot install this function.

Are there any elegant and / or practical solutions? The function is quite complicated with a number of parameters, so I was hoping there was a syntax that would allow me to mark the section of my request as a function, and then call this code from the main body of the request.

I tried Google, but unfortunately, as you might imagine, the words associated with this only lead to articles on how to create functions.

Edit: For this, I am limited to the functionality of SQL Server 2000.

+4
source share
3 answers

My best answer so far came from me. I saved the data that I need to process in a #temporary table, and then used a while loop with logic that required updating rows in the #temporary table. A lot of alterations, but it worked, and as a launch operation, I'm fine with that.

+1
source

Can't you just create an inline function? The create function does not work because you do not have authority? You could replace the CTE.

CREATE FUNCTION fn_Test ( @sID nvarchar(30) ) RETURNS table AS RETURN ( SELECT sID, sParID FROM docSVsys WHERE sID = @sID ) GO -- Example of calling the function for a specific region SELECT * FROM fn_Test(N'2') GO 
+1
source

I do not know if this is possible in MSSQL 2000, but you could create a function on tempdb and use it there.

In 2008, it seems to work. Therefore, if you have rights to this on tempdb, this may work.

0
source

All Articles