title: SQL Server stored procedure parameters data type error
body: <p>The following stored procedure in SQL Server 2008 was throwing an error    </p>
  
  <pre><code>/****** Object:  StoredProcedure [dbo].[UpdateCPA]    ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[pdateCPA_INT]
      @CPAColumn_Name nvarchar(100), @value Int, @RecordNum nvarchar(100)
  AS
  BEGIN
      SET NOCOUNT ON;
      --declare @CPAColumn_Name nvarchar(100) = 'UsrsID'
      --declare @value Int = 3575
      --declare @RecordNum int = 1
  
      declare @thedate smalldatetime
      set @thedate = GETDATE()
      --select @thedate as NOW
  
      declare @cmd nvarchar(max)
  
      set @cmd = 'Update tblTimeCPAReport 
      set ' + @CPAColumn_Name + ' = '+@value+' 
      set ReportLastUpdate = ' + @thedate + '
      where RecordNum='+@RecordNum
  
      exec sp_executesql @cmd
      select @cmd
  END
  </code></pre>
  
  <p>It's throwing this error</p>
  
  <blockquote>
    <p><em>Conversion failed when converting the nvarchar value 'Update
    tblTimeCPAReport set UsrsID = ' to data type int.</em></p>
  </blockquote>