Which is best stored procedure or simple query?

Author Topic: Which is best stored procedure or simple query?  (Read 8080 times)

Offline andrewneilTopic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 3
  • Karma: 0
Which is best stored procedure or simple query?
« on: 10-18-2012, 12:36:10 »
Please tell me which is best stored procedure or simple query and also tell me benefits of best one? O0


Offline pstpl1

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 14
  • Karma: 0
  • Gender: Female
  • ERP Software
    • ERP
Re: Which is best stored procedure or simple query?
« Reply #1 on: 11-30-2012, 02:45:40 »
As

Begin
If @p3 is null

Select * from table where field1=@p1 and field2=@p2

Else
Select * from table where field1=@p1 and field2=@p2 and field3=@p3
End
ERP Software [nofollow]
Payroll Software [nofollow]

Offline krishikaseo1

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 2
  • Karma: 0
  • Gender: Male
  • Ball Valves Manufacturer
    • PVC Ball Valves Manufacturer
Re: Which is best stored procedure or simple query?
« Reply #2 on: 02-07-2014, 00:07:06 »
Stored Procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most famillar with SQL Server I will use that as my samples.
newbielink:http://krishika.com[/url [nonactive]

Offline MarcoLeitner

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 2
  • Posts: 33
  • Karma: 0
  • Gender: Male
    • http://www.techiring.com
Re: Which is best stored procedure or simple query?
« Reply #3 on: 06-12-2015, 04:49:27 »
1.Stored procedure are stored queries in a database . They are pre compiled. when we request database to execute stored procedure , sql server already has the plan to execute stored procedure. while in case of simple query, it needs to create execution plan on runtime.

2. Stored procedure are pre compiled and optimised which means query engine can execute them more rapidly where as in case of simple query code must be parsed, compiled and optimised at run time which takes more time.

Offline Ghazala

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 0
  • Posts: 61
  • Karma: 0
Re: Which is best stored procedure or simple query?
« Reply #4 on: 03-10-2016, 02:31:44 »
Hello All,

The stored procedure is a set of PL/SQL statements written inside a named block. We use stored procedures in Sql Server to perform the very basic operations on database tables.

Thanks


 

Related Topics

  Subject / Started by Replies Last post
1 Replies
2221 Views
Last post 08-24-2011, 09:29:23
by takeshiro
2 Replies
1274 Views
Last post 03-25-2015, 08:00:20
by Lipipaliwal
0 Replies
428 Views
Last post 08-11-2016, 07:09:13
by beingchinmay
0 Replies
380 Views
Last post 10-12-2016, 03:11:56
by beingchinmay
0 Replies
292 Views
Last post 10-13-2016, 05:30:37
by beingchinmay