无法在sql server 2005的sql查询中调用用户定义的函数

时间:2013-01-24 06:57:14

标签: sql-server

我无法在sql server的sql查询中调用用户定义的函数。

我的qyery是

SELECT Empnum(delimeter_test) as del FROM FNSPLIT_TEST WHERE Len(delimeter_test) >1

我的功能是

ALTER FUNCTION [dbo].[Empnum] (@RAWDATA NVARCHAR(300))
RETURNS VARCHAR(30)
AS
BEGIN 
DECLARE @TEMP1 NVARCHAR(300)
--DECLARE @TEMP2
IF(CHARINDEX('Disabled',@RAWDATA,1)) <> 0
BEGIN
    DECLARE SPLITTEXT CURSOR FOR 
    SELECT [item] FROM fnSplit(@RAWDATA,',')
--  SET @TEMP1=dbo.fnSplit(@RAWDATA,',')
    OPEN SPLITTEXT
    FETCH SPLITTEXT INTO @TEMP1
    CLOSE SPLITTEXT
    DEALLOCATE SPLITTEXT
--  INSERT INTO @EMPNUM1 SELECT @TEMP1
--  SET @TEMP1=dbo.fnSplit(@RAWDATA,',')
END
RETURN @TEMP1
END

1 个答案:

答案 0 :(得分:1)

出于某种原因 UDF的需要架构名称:

SELECT dbo.Empnum(delimeter_test) as del FROM FNSPLIT_TEST WHERE Len(delimeter_test) > 1

此外,这是一种在没有游标的情况下连接文本字符串的方法:

Concatenate many rows into a single text string?