title: Function calling procedure gives error "Only functions and some extended stored procedures can be executed from within a function"
body: <p>I created a function like this:</p>
  
  <pre><code>CREATE FUNCTION [dbo].[GetAnnouncementID]() 
  RETURNS INT
  AS
  BEGIN
      DECLARE @AnnouncementID int 
      EXEC @AnnouncementID = DB1.dbo.PROC_GetID 
      RETURN @AnnouncementID
  END
  GO
  </code></pre>
  
  <p>Then I tried to use <code>select dbo.GetAnnouncementID()</code> to get the return value, but the error message is:</p>
  
  <blockquote>
    <p>Only functions and some extended stored procedures can be executed from within a function.</p>
  </blockquote>
  
  <p>How to fix it?</p>