我无法在 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