Home > SQL Server 2005/08 > Why to use StoredProcedures ?

Why to use StoredProcedures ?

Stored Procedures can be reused from different webpages, classes or webapplication where in case of coding sql statements you have to write code in each and every place.

Stored Procedures uses parameters to receive user input values so helps to prevent SQL injection.

Stored procedure are in complied form i.e they are already in compiled mode you nedd need to call them in your application. wherein when you write sql query the processor has to parse it, analyze it and execute it. so the stored procedure are faster than coding sql queries.

Stored Procedures are easy to debug.

Also from security point of view we can provide credentials to execute the stored procedure so this means that users access to the database can be defined by only allowing them permissions to execute the allowed stored procedures while denying them permissions to the underlying database objects such as tables and views that are used by the stored procedures.

Categories: SQL Server 2005/08
  1. Dhiraj
    August 25, 2009 at 9:46 am | #1

    Is there is a possibility of SQL Injection in Stored Procedure?

    • Sunil Yadav
      August 25, 2009 at 9:56 am | #2

      Mainly SQL Injection attacks are found in dynamic sql queries, for instance if you are using sp_executesql to execute a Transact-SQL statement or batch. MS also says that use of sp_executesql can lead to malicious attack like sql injection.
      http://msdn.microsoft.com/en-us/library/ms188001.aspx

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.