Calling Stored Procedure

What I am trying to do (Excuse syntax, its not meant to run, just a roadmap.)
crate MANY stored procedures
Most have up to 3 parameters
I want my vb code to call procedures and supply only relevant parameters
So my stored procedure is like
alter procedure
Param1 int = 0, Param2 int = 0, Param3 char(20) = ' ', param4 char(20) = ' ', param5 Datimtime = getdate(), Param6 Datetime = GetDate()
My first procedure uses Param1 and param5
My Second procedure uses Param2 and param4
My first procedure uses Param1 and param6
Etc etc etc
Can the code be written to only supply these values or do I have to supply for alll params.
Hope this makes sense
And if so an example woould be great

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

valkyrie_ncConnect With a Mentor Commented:
So long as you have defaults assigned for the input parameters in the stored procedure, you can send in only the params you prefer.  The declaration you have above (Param1 int = 0, Param2 int = 0) is perfect.  If any param is required by the proc, just remove the = [whatever].


you cannot do it so that you only specify param2 and 4 as you want. The only possibility is what's described below: 
the other possibility is that you try something like below

exec yourprocedure @param2 = 1, @param4 = 'something'

exec yourprocedure @param1 = 0, @param5 = 'something'

Open in new window

All Courses

From novice to tech pro — start learning today.