Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL and stored procedures
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL and stored procedures

 Post Reply Post Reply
Author
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Topic: SQL and stored procedures
    Posted: 17 February 2004 at 4:07pm

yo.. when using simple SQL statements like this


strSQL = "SELECT " & strDbTable & "SubCategories.* FROM " & strDbTable & "SubCategories "
strSQL = strSQL & "WHERE " & strDbTable & "SubCategories.Category_ID = " & lngCategoryID & " "
strSQL = strSQL & "ORDER BY " & strDbTable & "SubCategories.Sub_category_name DESC"

is there any need for Stored Procedures then? does it make any difference on performance (and other things)?



Edited by Semikolon
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:11pm
Stored procedures (SP) are more secure (dont ask me why) and they execute faster on the database.  SP syntax is very simple to learn, and just adds that edge to your software.  Not necessary, probably wont even notice a difference with them but might as well have them imo.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:13pm
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:19pm

SP's are precompiled so they perform better, all you have to do is

CREATE PROCEDURE [name]

(

[params]

)

AS

[query]

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:48pm
The main reason that they are fast is not necessarily because they are pre-compiled but because SQL has a and execution plan for it which may improve performance.
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:54pm

(I know how to use Stored Procedures)

so theres no BIG differences between SQL query in the code and Stored Procedures on queries like that?

the reason why i ask this is that its twice as much work when changing an SQL statement if making a script for both access and SQL server if i use stored procedures

 

for me it sounds ineffective with stored procedures (first call them from the script, then query the table(s) and send it back to the script instead of a direct call to the table(s)) but that may be me...

 

but thanks for ya help guys i appreciate it

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2004 at 4:59pm

For long quries like that you should use an sp, for one reason it will make your code look neater. It will also have performance advantages beacuse their precompiled and as Michael said:

Originally posted by michael michael wrote:

SQL has a and execution plan for it which may improve performance.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.