title: SQL Function Replacing 0 with Null
body: <p>Hi on the contrary to what I found on the internet, I need to replace a 0 with a null so that in the table i will have a null instead of a 0.</p>
  
  <p>Currently I did the following:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE FUNCTION retunNull(@num nvarchar(255))
  RETURNS nvarchar(255)
  AS
  BEGIN
      IF(@num IS '0')
          BEGIN
          @num = NULL
          END
          RETURN @num
  END
  GO
  </code></pre>
  
  <p>this is giving me the following error:</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Procedure retunNull, Line 6
    Incorrect syntax near '0'.
    Msg 102, Level 15, State 1, Procedure retunNull, Line 11
    Incorrect syntax near 'END'.</p>
  </blockquote>
  
  <p>Can anyone help me and guide me to the right direction?
  PS This must be done in a function since it will be used several times</p>