title: How to run a function inside a cursor in SQL
body: <p>I am very new to cursor. But I am trying to run a self-defined function inside a cursor. The function works. But no data was shown, if the cursor was ran. How can I fix it? Your inputs will be appreciated. Thanks.</p>
  
  <pre><code>DECLARE @fName varchar(50), @lName varchar(50)
  DECLARE cursorName CURSOR
  
  LOCAL SCROLL STATIC
  
  FOR
  SELECT fName, lName FROM TABLEA
  OPEN cursorName 
  
  FETCH NEXT FROM cursorName
     INTO @fName, @lName
  
  WHILE @@FETCH_STATUS = 0
  BEGIN
  
      SELECT * FROM dbo.data (@lName, @fName) 
      FETCH NEXT FROM cursorName
      INTO @fName, @lName
  
  END
  CLOSE cursorName 
  DEALLOCATE cursorName
  </code></pre>