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
 General SQL Server Forums
 New to SQL Server Programming
 Queries or SP

Author  Topic 

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-02-10 : 00:29:41
Hi

Do all the applications use Storede procedures & not queries. I mean when we use the ADO connection. Is it better to use stored procedsure alsways or could we do with the rs.Open "Select statment"

Please advice

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-02-10 : 01:42:15
for security reasons:
native queries are a threat, they do not only provide the user direct access to the tables, but the schema is quite exposed too,

sql injections can occur too since the queries are constructed at the apps level

for performance:
quote:
from bol

Effects of Stored Procedures on Application Performance
All well-designed Microsoft® SQL Server™ 2000 applications should use stored procedures. This is true whether or not the business logic of the application is written into stored procedures. Even standard Transact-SQL statements with no business logic component gain a performance advantage when packaged as stored procedures with parameters. Transact-SQL statements compiled into stored procedures can save a significant amount of processing at execution time. For more information, see Stored Procedures.

Another advantage of stored procedures is that client execution requests use the network more efficiently than equivalent Transact-SQL statements sent to the server. For example, suppose an application needs to insert a large binary value into an image data column. To send the data in an INSERT statement, the application must convert the binary value to a character string (doubling its size), and then send it to the server. The server then converts the value back into a binary format for storage in the image column. In contrast, the application can create a stored procedure of the form:

CREATE PROCEDURE P(@p1 image) AS INSERT T VALUES (@p1)

When the client application requests an execution of procedure P, the image parameter value will stay in binary format all the way to the server, thereby saving processing time and network traffic.

SQL Server stored procedures can provide even greater performance gains when they include business services logic because it moves the processing to the data, rather than moving the data to the processing.




--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-10 : 01:43:03
If you use Stored Procedure then it is cached in the memory so that next run will give you result quickly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-02-10 : 01:57:41
Thanks
Go to Top of Page
   

- Advertisement -