A : Stored procedure will be used for perform specific tasks
B : Normally functions will be used for computing value
Difference 2:
A : Stored procedures may or may not return values
B : But function should return value
A : Stored procedures may or may not return values
B : But function should return value
Difference 3:
A : Stored procedure cannot be used in the select/where/having clause
B : But function can be called from select/where/having clause
A : Stored procedure cannot be used in the select/where/having clause
B : But function can be called from select/where/having clause
Difference 4:
A : Stored procedure can run independently. It can be executed using EXECUTE or EXEC command
B : But function cannot run independently
A : Stored procedure can run independently. It can be executed using EXECUTE or EXEC command
B : But function cannot run independently
Difference 5:
A : Temporary table (derived) cannot be created on function.
B : But it can be created in stored procedures
A : Temporary table (derived) cannot be created on function.
B : But it can be created in stored procedures
Difference 6:
A : Stored procedure can call the user defined functions
B : But the function cannot call the stored procedures.
A : Stored procedure can call the user defined functions
B : But the function cannot call the stored procedures.
Difference 7:
A : From sql server 2005 onwards, TRY CATCH statements can be used in the stored procedures.
B : But it cannot be used in the function. But we can use raise error function.
A : From sql server 2005 onwards, TRY CATCH statements can be used in the stored procedures.
B : But it cannot be used in the function. But we can use raise error function.
Difference 8:
A : Stored procedures can have input and output parameters.
B : But the function can have only input parameters.
A : Stored procedures can have input and output parameters.
B : But the function can have only input parameters.
Difference 9:
A : Stored procedures can have select and all DML operations.
B : But the function can do only select operation.
A : Stored procedures can have select and all DML operations.
B : But the function can do only select operation.
Difference 10:
A : Function cannot have the transaction statements.
B : Stored procedure can use transaction statements.
A : Function cannot have the transaction statements.
B : Stored procedure can use transaction statements.
Difference 11:
A : Stored procedures can use all the data types available in sql server.
B : But the function cannot use the ntext, image and timestamp data types as return type.
A : Stored procedures can use all the data types available in sql server.
B : But the function cannot use the ntext, image and timestamp data types as return type.
Difference 12:
A : Stored procedures can create table variable and cannot return the table variable.
B : But the function can create, update and delete the table variable. It can return table variable.
A : Stored procedures can create table variable and cannot return the table variable.
B : But the function can create, update and delete the table variable. It can return table variable.
Difference 13:
A : Stored procedure can have the dynamic sql statement and which can be executed using sp_executesql statement.
B : But the function cannot execute the sp_executesql statement
A : Stored procedure can have the dynamic sql statement and which can be executed using sp_executesql statement.
B : But the function cannot execute the sp_executesql statement
Difference 14:
A : Stored procedure allows getdate () or other non-deterministic functions can be allowed.
getdate(),DB_ID(),DB_NAME ()
B : But the function won't allow the non-deterministic functions.
A : Stored procedure allows getdate () or other non-deterministic functions can be allowed.
getdate(),DB_ID(),DB_NAME ()
B : But the function won't allow the non-deterministic functions.
No comments:
Post a Comment