title: I can't get this error fixed : conversion failed when converting the nvarchar value
body: <p>I am a newby at sql and can find the problem with my query, I am getting this error:
  Msg 245, Level 16, State 1, Line 10
  Conversion failed when converting the nvarchar value '00999-00-210312-11' to data type int.</p>
  
  <pre><code>Declare @Referenceid Int
  
  SET @Referenceid = (
                      SELECT TOP 1 (CASE WHEN ad.ReferenceID LIKE '%NO ID%' THEN (RIGHT(MAX(ad.ReferenceID),2)+10)END) 
                      FROM Campaign.dbo.Assets_DailyBulkImport AS ad
                      WHERE (ad.ReferenceID IS NOT NULL)
                      GROUP BY ad.ReferenceID
                      ORDER BY ad.ReferenceID DESC);
  
  Select (c.Note + '' + '999' + N'-' + '00' + N'-' +
                        (SELECT     REPLACE(CONVERT(VARCHAR(8), GETDATE(), 3), '/', '') AS MMDDYY) + N'-' + @Referenceid)
                    FROM  Assets_DailyBulkImport AS a INNER JOIN
                          Controls_Profiles AS c ON a.Profile = c.Venture
                    where a.ReferenceID=@ReferenceID
  </code></pre>