SQL Query Vs Stored Procedures

  • Which is good to use in which case & why?

    SQL Query or Stored Procedures

    for example

    I want to do operation like insert/update/delete/Select

    Both way I can do it.

    Which is good? and Why?

  • It will depend on the situation.

    Today's editorial is somewhat anti-stored procedure (I happen to mostly agree with the editorial) and there are comments on the other side of the fence.

    http://www.sqlservercentral.com/articles/Editorial/63870/[/url]

  • There's really not a difference between a query and a procedure. A procedure is just a query stored in the database. Queries can be parameterized just like queries. In fact, that's one of the best ways to do dynamic queries (building the query through code instead of storing it in a procedure).

    I wouldn't say that a dynamic query is better than a stored procedure or vice versa. I think both have their place and you need to be flexible enough to acknowlegde where one works better than the other. Going all one way or all the other is foolish.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Read Steve's editorial from today.

  • Scott White's editorial, actually.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply