1

Possible Duplicate:
Function vs. Stored Procedure in SQL Server

I want to know what the differences between a stored procedure and a function in SQL Server are?

And where each one is used in ?

For example I have just written a stored procedure and I have finished it with

return @@Identity 

So can we say is this a function because this will return a value?

These sort of problems has made me distracted.

Community
  • 1
  • 1
Mahmood Hesabi
  • 59
  • 1
  • 1
  • 7
  • 1
    search on google. I did.. About 698,000 results (0.32 seconds) – Mudassir Hasan Oct 03 '12 at 06:40
  • Here it is.. http://stackoverflow.com/questions/1179758/function-vs-stored-procedure-in-sql-server – Vishwanath Dalvi Oct 03 '12 at 07:00
  • Also: you should [use `SCOPE_IDENTITY` instead of `@@IDENTITY`](http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/) – marc_s Oct 03 '12 at 07:47
  • 1
    "can we say is this a function because this will return a value?". If it begins `CREATE PROCEDURE` then it is a procedure. If it begins `CREATE FUNCTION` then it is a function. – Martin Smith Oct 03 '12 at 08:06

0 Answers0