Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

stored procedure vs function - What's the difference?

Asked by Aalap Prabhakaran Mar 13, 2023 1.0K views 1 answer
Share

About this question

There is a slight difference in "Stored Procedures" and "Stored Functions" in PostgreSQL.

I saw a wikipedia article but some of this doesn't seem to apply (e.g. that they can be used in a SELECT statement).
The syntax itself seem to be a little bit confusing:
CREATE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$
    BEGIN
       [...]
    END;
$emp_stamp$ LANGUAGE plpgsql;

CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp  FOR EACH ROW EXECUTE PROCEDURE emp_stamp();

You create a FUNCTION but refer to it as a PROCEDURE.

So what's the difference between these two?

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.