udf

[Managed UDF/ SqlServer2005 ] How to force dbo schema name?

I'm using "SQL SERVER PROJECT" in VS 2008 to create UDF in C# Then I'm using DEPLOY command to publish DLL into MS SQL server 2005 All works well except all created UDFs are owned by me (as user) But I wanted to keep dbo schema (eg: dbo.UDF_TEST - not jonny.UDF_TEST) Any idea how to manage thar? ...

How do you decide what to use: UDF or Custom Tag?

WACK says: If you feel you need to have lots arguments, consider creating a CT instead. ... CT are significantly more powerful and flexible than custom functions. Try to use UDF's for simple matters... Use CT and Components for more involved processes, especially those you can think of as discrete actions rather ...

Creating an excel worksheet function (UDF) at runtime in C#

Hey all Is it possible to create worksheet functions dynamically in C#, that is, without using the method attribute approach? Or is this something that's only supported using an XLL? What I'm looking at achieving is to retrieve a functions list (along with parameters) from a source and register these functions. These functions will jus...

Solving Erratic Behavior with HttpWebrequest in SQL 2008 CLR UDF

We're currently attempting to implement a sql server 2008 udf to do expansion of shortened urls. We have it working quite well against most of the major url shortening services. However, at seemingly random times it will "hang" and refuse to work against a certain domain (for example bit.ly) while subsequent calls to other services...

How to determine the number of days in a month in SQL Server?

I need to determine the number of days in a month for a given date in SQL Server. Is there a built-in function? If not, what should I use as the user-defined function? ...

Why Is My Inline Table UDF so much slower when I use variable parameters rather than constant parameters?

I have a table-valued, inline UDF. I want to filter the results of that UDF to get one particular value. When I specify the filter using a constant parameter, everything is great and performance is almost instantaneous. When I specify the filter using a variable parameter, it takes a significantly larger chunk of time, on the order of...

How do I write, compile and use a user defined function for mysql running on Windows 2003 server?

I am using - MySQL v 5.0.22, PHP v 5.2.0, Windows 2003, Apache. My skills - Basic PHP knowledge, Basic MySQL. What is the best way for me to write and use a mysql user defined function in my PHP scripts? ...

Writing a MySQL UDF using C++ STL functionality

There is a statement in the MySQL Docs (http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html) that is bothering me: "A UDF contains code that becomes part of the running server, so when you write a UDF, you are bound by any and all constraints that otherwise apply to writing server code. For example, you may have problems if you at...

Round in MS SQL on 0.05 or 0.00

Hello I am coming from Bosnia and Herzegovina and in our county the smallest note bill is 0.05, Now the government pushing us to our retrial prices rounding on 0.05 or at 0.00. Therefor I want to create SQL Scalar Valued Function for rounding the prices on given value. Is there some build in solution so I can save resource of my querie...

How can I optimize this horrendously inefficient User Defined Function in SQL Server 08

Is there anyway to optimize this horrible inefficient UDF in SQL Server 08. I am fairly new to UDF's and especially looking at them for optimizations. UPDATE: Should I be sending a column to a function like this if I wanted to perform it on each row and each column in a query? Is there a better way to go about this? Thank You ** @v...

How to cache server connections behind MySQL native UDFs

The MySQL UDF system doesn't provide a good way to have long-term persistent state. I want to be able to write a function that takes the name of a server, and some other arguments, that connects to the server and sends a request, and returns the result. But connecting to the server is a heavyweight operation (much more than just opening...

CLR UDF returning Varbinary(MAX)

Is it possible for a SQL CLR User-Defined Function to return the data type varbinary(MAX)? In the documentation it mentions: "The input parameters and the type returned from a scalar-valued function can be any of the scalar data types supported by SQL Server, except rowversion, text, ntext, image, timestamp, table, or cursor." - they d...

Help with slow UDF in SQL Server 2005

I have a table of dates call [BadDates], it has just one column where every record is a date to exclude. I have a UDF as follows: CREATE FUNCTION [dbo].[udf_GetDateInBusinessDays] ( @StartDate datetime, --Start Date @NumberDays int --Good days ahead ) RETURNS datetime AS BEGIN -- Declare the return variable here DECLARE ...

Can an excel worksheet be used as UDF?

I'm building a network business model in excel. A similar model is that of Gawker Media. In my model I have a number properties that have some over lap of audience. Each property attracts users, which in turn affords cross promotional opportunities. In the case of Gawker they have a series of blogs whose audience will likely read s...

How to match two email fields where one contains friendly email address

One table has "John Doe <[email protected]>" while another has "[email protected]". Is there a UDF or alternative method that'll match the email address from the first field against the second field? This isn't going to be production code, I just need it for running an ad-hoc analysis. It's a shame the DB doesn't store both friendly and non-fri...

How to use recursive table valued function in SQL SERVER 2005

I am making a split function in SQL Server 2005. I have already done it by using a while loop . But I am not happy with that. I want to do it using recursive function. I have already done it in C#. Now I am plotting the same in SQL SERVER 2005. But I am getting a compilation error. Here is my code ALTER FUNCTION [dbo].[fnSplit2] ( ...

t-sql udf, get the data type of a parameter

is it possible to get a numeric parameter to my udf and do stuff according to its type, like: if type of @p1 is decimal(10,3) ... else if type of @p1 is decimal(15,3) ... else if type of @p1 is integer ... ...

sql server udf, return the same type as the input expression

is it possible for a udf to return the same data type as one of its parameters? i would like my udf to accept a decimal of any precision and scale and return the same type. ...

How to strip all non-alphabetic characters from string in SQL Server?

How could you remove all characters that are not alphabetic from a string? What about non-alphanumeric? Does this have to be a custom function or are there also more generalizable solutions? ...

How to use SQL user defined functions in .NET?

Hello I created a scalar function in the DB SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER FUNCTION [dbo].[fn_GetUserId_Username] ( @Username varchar(32) ) RETURNS int AS BEGIN DECLARE @UserId int SELECT @UserId = UserId FROM [User] WHERE Username = @Username RETURN @UserId END Now I want to ru...