Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello im asking a simple question... where can i use a proc/ a fn/ single line query??
Posted

1 solution

[I assume you mean Stored Procedure by Proc,Function by fn]
Refer to this link.
When should you use stored procedures?[^]

It states that.
Quote:
One way to look at stored procedures is as an interface for your database. Clients call the stored procedure and don't worry about the implementation. As long as the signature doesn't change, the DBA is free to modify the underlying schema without affecting clients.

Use stored procedures when you have functional computations that can't be done in declarative SQL and are best left in the database.

Use stored procedures if you aren't worried about multiple database platforms and will never, ever migrate.

Advantages of using stored procedures:[ what are the advantages of using stored procedures in sql server[^]]

-Stored procedure allows modular programming.

You can create the procedure once, store it in the database, and call it any number of times in your program.

-Stored Procedure allows faster execution.

If the operation requires a large amount of SQL code is performed repetitively, stored procedures can be faster. They are parsed and optimized when they are first executed, and a compiled version of the stored procedure remains in memory cache for later use. This means the stored procedure does not need to be reparsed and reoptimized with each use resulting in much faster execution times.

-Stored Procedure can reduce network traffic.

An operation requiring hundreds of lines of Transact-SQL code can be performed through a single statement that executes the code in a procedure, rather than by sending hundreds of lines of code over the network.

-Stored procedures provide better security to your data

Functions are used when the repetitive task is to be done,for example,if you want to find sum of two numbers than make function that will return sum of two numbers and pass the values to that function.So each time you wont have to write code for the same task.

Functions- The complete C# Tutorial[^]

Query is used to perform actions related to database.E.g. Fetch data from database,Update details,insert new records etc.

Structured Query Language[SQL][^]

Regards..:laugh:
 
Share this answer
 
v7
Comments
Adarsh chauhan 29-Jul-13 3:19am    
Nice explanation.
+5
Thanks7872 29-Jul-13 3:19am    
Thanks Adarsh.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900