简体   繁体   中英

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?

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.

Put them in an XML and try OPENXML feature.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM