title: Error Handling in SQL UDF
body: <p>I am creating a UDF in SQL Server. I can not use try-catch block in a user defined function. How can I handle an exception or error in UDF?</p>
  
  <pre><code>CREATE FUNCTION GET_POLICY_NO
  (@POLICYID nvarchar(15))
   RETURNS varchar(30)
   AS
   BEGIN
   declare @Return varchar(30)
   select @return = (SELECT POLICY_NO FROM tblPolicy WHERE POLICY_ID = @POLICYID)
  return @return
   end
  </code></pre>
  
  <p>Although tblPolicy is Not exist, it will through error. How can I handle like SP?</p>