Ahmet Altun
Ahmet Altun

Reputation: 4049

Creating Stored Procedure With Variable Number of Parameters

I want to create a SQL Server stored procedure with a varying number of parameters. It is similar to "params" in C#.

How can I do it?

Upvotes: 3

Views: 3180

Answers (2)

Jith
Jith

Reputation: 1701

Put them in an XML and try OPENXML feature.

http://msdn.microsoft.com/en-us/library/ms186918.aspx

Upvotes: 4

marc_s
marc_s

Reputation: 755451

You cannot.

What you can do is provide a default value for some of your stored procedure parameters, so you don't have to specify them when calling your stored procedure.

If you're on SQL Server 2008 or up, you could also investigate the table-valued parameter (or here) - basically the ability to pass in a table of data to your stored procedure. Maybe that'll help.

Upvotes: 4

Related Questions