6
Answers

The most important Different in Stored Procedure & Function

There are lot differents are between Stored procedure & UDF. But, what is most important different from SQL Stored procedure and User defined function. Only one different, it should be valid and why it is important different.?
 
Answers (6)
1
Vinay Singh

Vinay Singh

NA 5.9k 126.1k 8y
We can use UDF in SP but we can not use SP in UDF
1
Jisny Av

Jisny Av

NA 473 46.8k 8y
<strong>Function</strong> must return a value but in <strong>Stored Procedure</strong> it is optional( <strong>Procedure</strong> can return zero or n values). <strong>Functions</strong> can have only input parameters for it whereas <strong>Procedures</strong> can have input/output parameters . <strong>Functions</strong> can be called from <strong>Procedure</strong> whereas <strong>Procedures</strong> cannot be called from <strong>Function</strong>.
1
Joginder Banger

Joginder Banger

NA 10k 490.6k 8y
Hi Hariharan,
In store procedure you can insert,update,delete data but in function only select data.
this is a main difference between store procedure and function.
0
Krishna Rajput Singh

Krishna Rajput Singh

NA 5.5k 2m 8y
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y

From the tone of the question, it is not clear if you genuinely asking the question or just testing our knowledge. Anyway!

Apart from the TWO major differences mentioned already, another major difference is you cannot use output returned from sp in a join but can use returned from user defined TVF.

Furthermore you only mention UDF but don't differentiate between Scalar function and TVF.
0
Ehsan Sajjad

Ehsan Sajjad

NA 5k 425.9k 8y
Stored Procedure can return multiple result sets while Function can only return single result set which means that in Stored procedure you can have multiple select statements while in Function you cannot have that.