Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Difference between User defined Functions and Stored Procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-29 : 07:44:38
Manmath writes "What are the major differences between User Defined Functions and Stored Procedures in SQL Server 2000?"

SqlStar
Posting Yak Master

121 Posts

Posted - 2003-08-29 : 09:08:56
Hi,

I think the following points will give some clarity to you.

As you may've guessed, a UDF is in some ways similar to a stored procedure. Here’s a list of how UDF's are different to stored procedures:

Scope of modification: UDF's aren't allowed to modify the physical state of a database using INSERT, UPDATE or DELETE statements. They can only work with local data.

Output parameters: UDF's don't have the ability to return output parameters to the calling function. They do however let us return a single scalar value or a locally created table.

Error handling: In UDF's, if an error occurs during a call to a stored procedure or a trigger, then that statement is terminated and flow control continue through the UDF.

Calling conventions: One of the major differences between UDF's and stored procedures is that a UDF can be called through a SQL statement without using the EXECUTE statement.

Thanks

":-) IT Knowledge is power :-)"
Go to Top of Page
   

- Advertisement -