title: unable to call a user defined function in sql query of sql server 2005
body: <p>Im unable to call a user defined function in an sql query of sql server.</p>
  
  <p>my qyery is </p>
  
  <pre><code>SELECT Empnum(delimeter_test) as del FROM FNSPLIT_TEST WHERE Len(delimeter_test) &gt;1
  </code></pre>
  
  <p>and my function is </p>
  
  <pre><code>ALTER FUNCTION [dbo].[Empnum] (@RAWDATA NVARCHAR(300))
  RETURNS VARCHAR(30)
  AS
  BEGIN 
  DECLARE @TEMP1 NVARCHAR(300)
  --DECLARE @TEMP2
  IF(CHARINDEX('Disabled',@RAWDATA,1)) &lt;&gt; 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
  </code></pre>