Re: charindex in user-defined function

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 10/16/04


Date: Sat, 16 Oct 2004 14:06:48 +0100

The problem with your function is that you didn't define the size of the
input parameters, therefore your strings get truncated to VARCHAR(1). For
example, change it to:

CREATE FUNCTION X(@p_str1 VARCHAR(30), @p_str2 VARCHAR(30))
 ...

Some non-deterministic functions can be used in a UDF but others aren't
permitted, mainly I think because of the difficulties that could result from
using those functions in queries or in conjunction other features that might
reference the UDF.

Your system date is incorrect. You may not get many replies because people
who sort posts by date won't see your post as a recent one.

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: charindex in user-defined function
    ... input parameters, therefore your strings get truncated to VARCHAR. ... Some non-deterministic functions can be used in a UDF but others aren't ... who sort posts by date won't see your post as a recent one. ...
    (microsoft.public.sqlserver.clients)
  • Re: charindex in user-defined function
    ... input parameters, therefore your strings get truncated to VARCHAR. ... Some non-deterministic functions can be used in a UDF but others aren't ... who sort posts by date won't see your post as a recent one. ...
    (microsoft.public.sqlserver.programming)
  • Re: Passing N Strings to a Function
    ... > The udf currently takes one string as an argument. ... > How can I pass multiple strings to a function? ... stored procedure - using an XML string. ... supports Post Alerts, Ratings, and Searching. ...
    (microsoft.public.sqlserver.programming)
  • Re: Can MySQL start/fire an external process?
    ... unbounded time, perform I/O, access other libraries, etc. ... DBMS server hanging if your UDF takes a long time to return ... UDFs are intended for very short-duration context-free operations, taking input parameters and giving output based solely on that input. ...
    (comp.lang.java.databases)
  • Passing N Strings to a Function
    ... The udf currently takes one string as an argument. ... How can I pass multiple strings to a function? ... I had planned to do it the same way we would pass multiple strings to a stored procedure - using an XML string. ... Posted using Wimdows.net NntpNews Component - Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching. ...
    (microsoft.public.sqlserver.programming)