Click here to Skip to main content
15,922,015 members
Home / Discussions / Database
   

Database

 
GeneralRe: stored procedures Pin
Giorgi Dalakishvili15-Sep-07 4:47
mentorGiorgi Dalakishvili15-Sep-07 4:47 
GeneralRe: stored procedures Pin
Paul Conrad15-Sep-07 4:56
professionalPaul Conrad15-Sep-07 4:56 
GeneralRe: stored procedures Pin
Giorgi Dalakishvili15-Sep-07 8:49
mentorGiorgi Dalakishvili15-Sep-07 8:49 
GeneralRe: stored procedures Pin
Paul Conrad15-Sep-07 9:35
professionalPaul Conrad15-Sep-07 9:35 
GeneralRe: stored procedures Pin
Giorgi Dalakishvili15-Sep-07 9:51
mentorGiorgi Dalakishvili15-Sep-07 9:51 
GeneralRe: stored procedures Pin
Paul Conrad15-Sep-07 10:03
professionalPaul Conrad15-Sep-07 10:03 
GeneralRe: stored procedures Pin
Giorgi Dalakishvili15-Sep-07 10:05
mentorGiorgi Dalakishvili15-Sep-07 10:05 
GeneralRe: stored procedures Pin
Paul.B18-Sep-07 22:57
Paul.B18-Sep-07 22:57 
Okay, so as far as I understand it, having variable SQL queries in a stored procedure (except the obvious WHERE clause exception) is generally a good way to screw up the execution plan... So, seeing your responses to the question, why didn't you just do the following? I'm using the Northwind Database as the test DB.

CREATE PROC TestIdead @number smallint
AS
if @number = 10
    begin
       select top 10 * from Customers
    end
else if @number = 20
    begin
       select top 20 * from Customers
    end
else if @number = 30
   begin
      select top 30 * from Customers
   end

In hindsight, you could probably reduce the IF...ELSE stuff down to a CASE statement as well... Just wondering why you opt for dynamic SQL queries rather than a logic structure that would result in a faster executing stored procedure (because the queries are static and thus don't modify the execution plan)?

I'm a bit new to SQL and stored procs, so please enlighten me. Smile | :)
GeneralRe: stored procedures Pin
Giorgi Dalakishvili18-Sep-07 23:19
mentorGiorgi Dalakishvili18-Sep-07 23:19 
GeneralRe: stored procedures Pin
Paul.B18-Sep-07 23:27
Paul.B18-Sep-07 23:27 
AnswerRe: stored procedures Pin
amraouf15-Sep-07 22:10
amraouf15-Sep-07 22:10 
Questionis there any possibility raise a problem Pin
prasadbuddhika14-Sep-07 21:29
prasadbuddhika14-Sep-07 21:29 
AnswerRe: is there any possibility raise a problem Pin
Paul Conrad15-Sep-07 4:07
professionalPaul Conrad15-Sep-07 4:07 
GeneralRe: is there any possibility raise a problem Pin
prasadbuddhika15-Sep-07 16:54
prasadbuddhika15-Sep-07 16:54 
QuestionSQL Security for your apps Pin
Mark Cabbage14-Sep-07 20:06
Mark Cabbage14-Sep-07 20:06 
AnswerRe: SQL Security for your apps Pin
Paul Conrad15-Sep-07 4:04
professionalPaul Conrad15-Sep-07 4:04 
GeneralRe: SQL Security for your apps Pin
Mark Cabbage15-Sep-07 4:49
Mark Cabbage15-Sep-07 4:49 
AnswerRe: SQL Security for your apps Pin
Mike Dimmick16-Sep-07 6:37
Mike Dimmick16-Sep-07 6:37 
GeneralRe: SQL Security for your apps Pin
Mark Cabbage16-Sep-07 15:24
Mark Cabbage16-Sep-07 15:24 
QuestionProblem with populating the FullText search Catalog Pin
Splunk14-Sep-07 7:47
Splunk14-Sep-07 7:47 
AnswerRe: Problem with populating the FullText search Catalog Pin
DerekFL14-Sep-07 7:58
DerekFL14-Sep-07 7:58 
QuestionNew rows that are added don't increment the PK field Pin
steve_rm14-Sep-07 3:17
steve_rm14-Sep-07 3:17 
AnswerRe: New rows that are added don't increment the PK field Pin
Michael Potter14-Sep-07 4:08
Michael Potter14-Sep-07 4:08 
QuestionRe: New rows that are added don't increment the PK field Pin
steve_rm14-Sep-07 7:52
steve_rm14-Sep-07 7:52 
AnswerRe: New rows that are added don't increment the PK field Pin
Michael Potter14-Sep-07 8:33
Michael Potter14-Sep-07 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.