|
I want to write Single stored proc for Insert,delete and update statements.Can you please help me?
(comments are locked)
|
|
Have you looked at the MERGE command? That allows you to pass data through a single statement and then conditionally insert, update or delete as needed. Here's the MSDN entry: http://msdn.microsoft.com/en-us/library/bb510625.aspx
(comments are locked)
|
|
Thank you all for replies!!! I got the answer from my friend!!! What was that answer? Edit your post and list it out so that others who are interested in the same thing that see your question will know what the answer was.
Jul 12 '12 at 07:56 AM
Grant Fritchey ♦♦
(comments are locked)
|
In this way I will pass all the variables from my VB6 application with an extra reference to Flag . So If that condition satisfies then the action will perform otherwise don't. In this way We can write only one Stored proc for all the operations. But if you've already worked out that the student exists (to set the right flag), why not call a different sp?
Jul 12 '12 at 10:43 AM
Kev Riley ♦♦
Yes, You can call other SPs also but it is the one way of writing less number of stored procs instead of different Sps for different operations.
Jul 13 '12 at 02:38 AM
tiru5796
Of course, everything in a single procedure like this means that all queries are compiled at the same time with a single set of parameter values. You might see poor performance for some queries since they'll be compiled with less than optimal values.
Jul 16 '12 at 08:58 AM
Grant Fritchey ♦♦
@Grant: No all the queries are not complied at the same time.One query executed at a time based on the condition satisified in the IF CALUSE.ok
Jul 16 '12 at 09:56 AM
tiru5796
But all queries within the procedure you outlined will be compiled the first time that procedure is called. That's how it absolutely works.
Jul 16 '12 at 10:59 AM
Grant Fritchey ♦♦
(comments are locked)
|


Can you please give us some information on the code you wish to include?
Without wishing to sound flippant - why on earth would you want to do this?
@Kev Riley - MERGE command?
+1 to Kev...
...and are you looking to write one procedure to do all of these operations against a single table, or are you wanting one procedure to run against all tables? (The first is relatively straightforward; the second, less so.)
@WilliamD - I hope you're right, but it didn't sound like it