mercredi 29 novembre 2017

SQL SERVER IF THEN ELSE in Stored Procedure

I have a stored procedure that I pass an integer parameters to (@truncate). What I want is this.

if @truncate = 1
then 
 truncate some_table 
   do something else

else 
   do only the "do something else" (before the else) without truncating the table.. 

The "do something else" part of the code is quite long.. How do I do this without repeating the "do something else" code and making the SP longer than necessary?

Aucun commentaire:

Enregistrer un commentaire