SQL多参数值

时间:2009-03-29 12:02:41

标签: sql-server-2005 stored-procedures

SQL 2005中有哪些选项可以将多个值传递给存储过程

Psuedo代码

在C#代码中

    List<string> myApplicationList;
    .... (code to assign values)
    **Construct parameter list**
    Call stored procedure [spSelectMaster] with myApplicationList

SQL存储过程

    CREATE PROCEDURE [Ecn].[spSelectMaster]
        **Need to declare parameter here but not sure what this would be**
    AS
    BEGIN
        SET NOCOUNT ON
        SELECT *
        FROM [dbo].[Master]
        WHERE [Master].[ApplicationKey] IN (@ApplicationList)
    END
    GO

提前致谢

1 个答案:

答案 0 :(得分:4)

SQL Server 2005 T-SQL中没有对数组的内置支持,但您可以解决此问题:

Arrays and Lists in SQL Server 2005

How to pass a list of values or array to SQL Server stored procedure?