Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 When to use stored procedures

Author  Topic 

kpgraci
Yak Posting Veteran

68 Posts

Posted - 2012-05-07 : 11:16:14
I have a web app that uses web services to read and write to a sql database.

I initially wrote all the queries as stored procedures because I was told that is the most efficient. The queries I use are rater basic, the retrieve one or more records based on parameters, or update a single record.

Later I read that doing a single query one at a time like this that stored procedures offered no real performance benefit. The discussion listed times when it would be beneficial to use stored procedures, and I don;t remember what that was but I did none of those things.

So for simple, call one at a time when the user requests a get or put operation, is there a performance benefit to using stored procedures?



kpg

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-07 : 14:15:37
Even if the queries are very simple and performance is not a consideration, I would try to use stored procs at least for two other reasons:

a) security
b) maintainability (for example, if you need to change the schema of a table, if you allow ad-hoc queries, you would be in a bind to dig out all the places in client code where they may be referring to the table).

And, performance is NEVER not a consideration, so stored procs would help in that too via plan reuse etc.
Go to Top of Page
   

- Advertisement -