title: SQL Rowcount always returning 1 on insert into command
body: <p>All I want to do is set a variable to the count of rows affected by the transaction and send that to a table. I don't know why I'm having trouble, but here is my code</p>
  
  <pre><code>Begin
  
  Declare @errDate datetime
  Declare @RowCount nvarchar(10)
  Declare @Message nvarchar(max)
  Declare @startproc datetime
  Declare @endproc datetime
  Declare @duration int
  set @startproc = getdate()
  
  Declare @myDate Datetime
  
  Set @myDate = CAST(CONVERT(varchar,getdate()-1, 112)   +' ' +'00:00 AM'AS DATETIME)
  
  DELETE FROM [Cal_CommOps].[dbo].[Progression_PreCall_CaliforniaECH]
           Where segStart_date = @myDate
  
  INSERT INTO [Cal_CommOps].[dbo].[Progression_PreCall_CaliforniaECH]
             ([callid]
             ,[segstart_date]
             ,[dialed_num]
             ,[origlogin]
             ,[duration])
  
  SELECT  *
  FROM               (
  Select callid,
           CAST ([SEGSTART_D] as datetime) as segstart_date,
           RIGHT(dialed_num, 10) as dialed_num,
           origlogin,
           duration
  FROM [CMS_ECH] ECH
  Inner join [Cal_CommOps].[dbo].[CommOps_Emp] EMP on EMP.extension = ECH.origlogin
  AND Dept in ('Pre-Call')
  Where [SEGSTART_D] = @myDate and dialed_num &lt;&gt; ''
  
  UNION
  
  Select callid,
           CAST ([SEGSTART_D] as datetime) as segstart_date,
           RIGHT(calling_pty, 10) as dialed_num,
           anslogin,
           duration
  FROM [CMS_ECH] ECH
  Inner join [Cal_CommOps].[dbo].[CommOps_Emp] EMP on EMP.extension = ECH.anslogin
  AND Dept in ('Pre-Call')
  Where [SEGSTART_D] = @myDate and calling_pty &lt;&gt; ''
  
                    ) as myCalls
  
  Set @RowCount = @@rowcount
  Set @endproc = getdate()
  Set @duration = DATEDIFF(minute, @startproc, @endproc)
  Set @errDate = getdate()
  
  Exec usp_myDashboardInsert 'PreCall_ECH', @@Rowcount, @errDate, @duration
  End
  </code></pre>
  
  <p>Even if I try</p>
  
  <pre><code>Exec usp_myDashboardInsert 'PreCall_ECH', @Rowcount, @errDate, @duration
  </code></pre>
  
  <p>I still get 1.</p>
  
  <p>Why is this and how do I fix it?</p>
  
  <p>If I change the code and add <code>Select @@ROWCOUNT</code> before <code>Set @RowCount = @@rowcount</code> then it works to select it, but I still want it in a variable.</p>
  
  <p>Answer: I guess it was the case of @@ROWCOUNT I was using @@Rowcount and it wanted @@ROWCOUNT.</p>