title: How to execute a procedure having cursor in SQL Server 2008?
body: <p>I know how to execute a stored procedure in SQL Server2008 but I'm clueless in executing a stored procedure containing a cursor in it.</p>
  
  <p>My code: </p>
  
  <pre><code> BEGIN TRANSACTION 
   GO
  
  DROP PROCEDURE SampleProcedure
  GO
  
  CREATE PROCEDURE SampleProcedure 
  AS 
      DECLARE @FirstName varchar(64)
  
      DECLARE c1 CURSOR READ_ONLY
      FOR
          SELECT FIRST_NAME
          FROM EMPLOYEE
  
      OPEN c1
  
      FETCH NEXT FROM c1 INTO @FirstName
  
      WHILE @@FETCH_STATUS = 0
      BEGIN
          PRINT @FirstName
  
          FETCH NEXT FROM c1 INTO @FirstName
      END
  
      CLOSE c1
      DEALLOCATE c1
  
      COMMIT TRANSACTION 
  </code></pre>
  
  <p>I have seen executing a procedure with cursor in Oracle but couldn't find in SQL Server. Please tell me how to execute the stored procedure which contains cursor.</p>
  
  <p>---Thanks</p>