Difference between Function and Procedure-in general?
Answer Posted / s.chandrahasan
A stored procedure is like a miniture program in SQL Server.
It can be as simple as a select statement, or as complex as
a long script that adds, deletes, updates, and/or reads data
from multiple tables in a database. (Stored procedures can
also implement loops and cursors which both allow you to
work with smaller results or row by row operations on data.)
The SQL Server functions are option for doing certain
operations in SQL Server. They can not be used to update,
delete, or add records to the database. They simply return a
single value or a table value. They can only be use to
select records. However, they can be called very easily from
within standard SQL, such as:
SELECT dbo.functionname('Parameter1')
OR
SELECT Name, dbo.Functionname('Parameter1') FROM sysObjects
For simple reusable select operations, functions can simply
your code. Just be wary of using JOIN clauses in your
functions. If your function has a JOIN clause and you call
it from another select statement that returns multiple
results, that function call with JOIN those tables together
for EACH line returned in the result set. So though they can
be helpful in simpling some logic, they can also be a
performance bottleneck if they're not used properly.
Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
Explain what are partitioned views and distributed partitioned views?
Using the customer, and order table in northwind database, please write a query to produce xml?
How to connect of datebase with sql express.?
What are Spatial data types in SQL Server 2008
What are magic tables in sql server?
How to transfer data from a cursor to variables with a "fetch" statement?
What is the difference function and stored procedure?
Explain about sql server login?
What happens if null values are involved in bitwise operations?
How fixed length strings are truncated and padded?
How to return the second 5 rows in ms sql server?
how you can deploy an ssrs report?
How to identify current user in ssrs report?
Define Joins?
What is attribute hierarchy? : sql server analysis services, ssas