SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Variable Parameter list for for procedure


Variable Parameter list for for procedure

Author
Message
Krishna1
Krishna1
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 556
Dear All

I need to create procedure with variable parmaeter list. I am trying to achive it through table value parameter.

Is it the correct approch?

Also I need this parameter to be optional. But when i give folloing syntax i get error
CREATE PROCEDURE [P1]
@param1 VARCHAR(40),
@ParameterTable ParameterTable READONLY = NULL
as
.....
sanket kokane
sanket kokane
SSC-Addicted
SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)

Group: General Forum Members
Points: 475 Visits: 1022
You can use default Stored Procedure Template from Template Explorer.
it will help you



SSMS > View > Template Explorer > Stored Procedure

-----------------------------------------------------------------------------
संकेत कोकणे
Eugene Elutin
Eugene Elutin
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4982 Visits: 5478
shilpaprele (11/6/2012)
Dear All

I need to create procedure with variable parmaeter list. I am trying to achive it through table value parameter.

Is it the correct approch?

Also I need this parameter to be optional. But when i give folloing syntax i get error
CREATE PROCEDURE [P1]
@param1 VARCHAR(40),
@ParameterTable ParameterTable READONLY = NULL
as
.....




Table-valued parameter is the best for passing table-like data, but not variable parameter list.
Let say you want to pass multiple Customer Id's together with relevant Customer Names. Table-valued parameter is upto this task.
But if you want to pass list of different parameters eg. not-related to each other and having different datatype, I would recommend using XML.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Krishna1
Krishna1
Old Hand
Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)Old Hand (350 reputation)

Group: General Forum Members
Points: 350 Visits: 556
I checked default template does not cater to my changing parameter reuirement. Also it is not showing me how to make table type paramter as optional
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search