udf

Efficient way to call a T-SQL built-in function from a .NET CLR UDF?

From a CLR UDF (C# syntax) is it possible to acquire a more or less direct handle to a built-in TSql function, instead of trying to kludge it into an ADO.NET SQL text like so? // Programming .inside NET CLR UDF: // Is there a more efficient way than this command? SqlCommand cmd... = new SqlCommand( ...'SELECT EncryptByKey(@Param, @Para...

Why are SQL-Server UDFs so limited?

From the MSDN docs for create function: User-defined functions cannot be used to perform actions that modify the database state. My question is simply - why? Yes, a UDF that modifies data may have potentially unwanted side-effects. Yes, there is overhead involved if a UDF is called thousands of times. But that is the whole point of d...

Migrating DB2 UDFs from AIX to Linux (RHEL)

I successfully compiled some UDFs on 64-bit Linux that were originally compiled on AIX Linux is running IBM DB2 v9.5 Here's the function that sometimes returns for some values #include <cstdlib> #include <cstdio> #include <iostream> #include "cbudf.hpp" using namespace std; extern "C" void SQL_API_FN cbzdt(SQLUDF_VARCHAR_FBD *pArg,...

How to call an extended procedure from a function

hi im having trouble trying to get the following function to work. CREATE FUNCTION test ( @nt_group VARCHAR(128) ) RETURNS @nt_usr TABLE ( [name] [nchar](128) NULL , [type] [char](8) NULL , [privilege] [char](9) NULL , [mapped login name] [nchar](128) NULL , [permission path] [nchar](128) NULL ) AS BEGIN ...

Profiling statements inside a User-Defined Function

I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together. In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't...

Identity column in SQL CLR Split UDF

How can I return a identity column with a standard SQL CLR Split UDF for example the code below will return a table with the string value split by delimiter, I need to somehow return an identity column as well. <SqlFunction(FillRowMethodName:="FillRow", TableDefinition:="value nvarchar(4000)")> _ Public Shared Function GetStrings(ByVal ...

Determining actual args an Excel UDF was called with.

I'm adding a user defined function to Excel with varargs-based signature in C++: LPXLOPER MyFunction(...); When Excel calls MyFunction, it passes it 30 arguments regardless of how many the user entered in the sheet. The extraneous ones are blank strings. MyFunction, however, is designed to accept empty string arguments. As a result, ...

Can an Excel VBA UDF called from the worksheet ever be passed an instance of any Excel VBA object model class other than 'Range'?

I'm 99% sure that the answer is "no", but I'm wondering if someone who is 100% sure can say so. Consider a VBA UDF: Public Function f(x) End Function When you call this from the worksheet, 'x' will be a number, string, boolean, error, array, or object of type 'Range'. Can it ever be, say, an instance of 'Chart', 'ListObject', or any...

Similarity between strings - SQL Server 2005

Hi, I am looking for a simple way (UDF?) to establish the similarity between strings. The SOUNDEX and DIFFERENCE function do not seem to do the job. Similarity should be based on number of characters in common (order matters). For example: Spiruroidea sp. AM-2008 and Spiruroidea gen. sp. AM-2008 should be recognised as sim...

SQL Server Multiple Joins Are Taxing The CPU

I have a stored procedure on SQL Server 2005. It is pulling from a Table function, and has two joins. When the query is run using a load test it kills the CPU 100% across all 16 cores! I have determined that removing one of the joins makes the query run fine, but both taxes the CPU. Select SKey From dbo.tfnGetLatest(@ID) a le...

Can I call a UDF at Frontend

I have a UDF in sql server. I want to call this function at frontend (C# Code). Is it possible to do it. ...

Excel 2007 UDF keeps failing, why?

I've been trying to browse info about this for a while now. The user defined functions in Excel 2007 just make no sense to me whatsoever. According to all the tutorials, it should be really simple. Just press alt + f11, insert a new module, and enter the VBA code there. At this point typing '=FUNCTIONNAME(parameters)' into any cell shou...

Complex derived attributes in Django models

What I want to do is implement submission scoring for a site with users voting on the content, much like in e.g. reddit (see the 'hot' function in http://code.reddit.com/browser/sql/functions.sql). Edit: Ultimately I want to be able to retrieve an arbitrarily filtered list of arbitrary length of submissions ranked according to their sc...

UDF function with library dependencies on MySQL 5.1

I'm having a problem with a MySQL UDF function (mychem.sourceforge.net) that's dependent on a large library (openbabel.org) which is in turn plugin based. The problem is that the format plugins to openbabel doesn't seem to load in MySQL 5.1 and I suspect it might be due to the plugin_dir setting. I have set plugin_dir to /usr/lib/ which ...

Is it possible to create an efficient UDF alternative to Excel's CUBEVALUE function?

We'd like to create a simpler alternative to Excel's CUBEVALUE function for retrieving data from an OLAP server. The details aren't critical, but briefly, our function will "know" the source connection and accept a very simple ticker-like parameter and a date, in place of CUBEVALUE's MDX-style parameters. This is for internal use within ...

SQL Split function that handles string with delimeter appearing between text qualifiers?

There are several SQL split functions, from loop driven, to using xml commands, and even using a numbers table. I haven't found one that supports text qualifiers. Using the example string below, I would like to split on ",", but not when it appears between double or single quotes. Example data: [email protected], "Sally \"Heat\" Jo...

mysql UDF : fopen = permission denied

EDIT: I've re-written this question, as I got no answer and I'm currently trying to narrow the problem. I'm trying to create a mysql UDF function checking if a file exists on the server side. This function calls "open/close". It doesn't work even when the file are readeable. I put the code for this function below: #include <mysql.h> #...

MySql UDF using shared library won't load

I am attempting to create a mysql UDF which will match a fingerprint using Digital Persona's free linux SDK library. I have written a trivial UDF as a learning experience which worked fine. However, when I added a dependency to Digital Persona's shared object I can no longer get MySql to load my UDF. I added includes to DP's headers a...

Can a sql server aggregate udf be passed in multiple parameters?

I am trying to write an aggregate udf for using Sql Server 2008 and C# 3.5 that implodes an aggregation of data. The kind of syntax I am looking for is: SELECT [dbo].[Implode]([Id], ',') FROM [dbo].[Table] GROUP BY [ForeignID] where the second parameter is the delimiter for the aggregate function. And example return value would be s...

How to create Automation Add In Formula/Function and Excel Add In buttons (vsto) for them together?

Ok, let me explain it little bit better. Here is one example how to create formula/functions http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/273127.aspx?PageIndex=1#comments I implemented something like that, I even added values in registry, so that this Automation AddIn doesn't have to be added manually in Excel, but automatic...