title: Create cursor for temporary table in sql server 2005
body: <p>I have some data inserted into the temporary table and I want to show <strong>COUNT</strong> in a LOOP by using <code>CURSOR</code></p>
  
  <p>Here is the temp table:-</p>
  
  <pre><code>SELECT * 
  INTO #temp
   FROM (
  select distinct a.CUser_id, b.User_Id, b.first_name + ' ' + b.last_name NAME
  from inward_doc_tracking_trl a, user_mst b
  where a.CUser_id = b.mkey
  and CStatus_flag = 1
  and NStatus_flag = 4
  ) AS x
  Select * from #temp order by NAME
  </code></pre>
  
  <p>[![TEMP TABLE data][1]][1]</p>
  
  <p>I am new to cursor, kindly help</p>
  
  <p>I am using <code>sql server 2005</code></p>