Here’s the declaration I’d like to have.
CREATE PROCEDURE UpdateTimeProc
(
@Hours int,
@Minutes int,
@Seconds int = 0,
@ResetCounter bit
)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, there is no requirement that parameters with default values must come before or after parameters without. But this means you need to name your parameters if you’re not including all of them. You cannot say…
…and expect
1to go with@ResetCounter. You’ll need to name the parameters (as Conrad’s answer shows) if you want to leave the optional parameter out.Let me repeat: the above syntax will NOT work.
You can optionally do it this way (you only have to start naming parameters after you’ve named the first one):
But I really don’t recommend it, since people will have to look up what the other parameters are. Generally we should prefer self-documenting code over terse code.