title: Error converting data type varchar to numeric. SQL Server
body: <p>I'm writing data on the Sql Server database. 
  When data is written, a trigger runs.</p>
  
  <hr>
  
  <p>TRIGGER</p>
  
  <pre><code>ALTER TRIGGER Alert ON records AFTER INSERT AS
  BEGIN
  
  DECLARE @tempmin decimal = 0
  DECLARE @current_max_idAlarm int = (SELECT MAX(IdAlarm) FROM alarms)
  DECLARE @maxidAlarm int
  DECLARE @temp decimal = (SELECT s.lim_inf_temp  from sensores s JOIN inserted i ON s.idSensor=i.idSensor )
  
  -- Insert into alares from the inserted rows if temperature less than tempmin
  SET IDENTITY_INSERT alarmes On
  INSERT alarmes (IdAlarm, desc_alarm,date, idRecord)
      SELECT
      ROW_NUMBER() OVER (ORDER BY i.idRecord) + @current_max_idAlarm, 'Temp Error', GETDATE(), i.idRecord
      FROM
  inserted AS i
      WHERE
  i.Temperature &lt; @temp
  
  end
  </code></pre>
  
  <hr>
  
  <p>INSERT</p>
  
  <pre><code>insert into record values ('2014-05-26' ,'14:51:47','Sensor01','---','48.6','9.8');
  </code></pre>
  
  <p>Whenever I try to record this type of data: '---'</p>
  
  <p>Gives the following error: </p>
  
  <pre><code>Msg 8114, Level 16, State 5, Procedure Alert, Line 
  Error converting data type varchar to numeric.
  </code></pre>
  
  <p>I know it is to be in decimal type (DECLARE @temp decimal - TRIGGER), but moving to the type varchar to trigger stops working correctly. </p>
  
  <p>Does someone can help me resolve this error please? </p>
  
  <p>Thank you all.</p>