如何在SQL Server存储过程中声明整数数组? [英] How do I declare array of integers in a SQL Server stored procedure?
问题描述
我有这个int []数组:
int [] arr = [1,23,4,3];
arr
变量我作为参数发送到存储程序。
如何声明此变量?如何在SQL Server存储过程中声明整数数组?
SQL Server没有任何数组类型 - 如果你需要多个值的东西,实际上只有一个结构:一个表。
如果您需要将多个值传递给存储过程,则应查看表值参数(TVP)。这些允许你发送一个满足值的表变量。
同样适用于你的存储过程 - 如果你需要处理多个值,使用一个表变量 @MyTable
)或常规临时表( #MyTempTable
)
I use SQL Server 2012.
I have this int[] array:
int[] arr = [1,23,4,3];
arr
variable I sent as parameter to stored procedure.
How do I declare this variable? How do I declare array of integers in a SQL Server stored procedure?
SQL Server doesn't have any "array" type - if you need multiple values of something, there's really only one construct : a table.
If you need to pass multiple values to a stored procedure, you should check out table-valued parameters (TVP). Those allow you to send in a "table variable" full of values.
Same applies inside your stored procedure - if you need to handle multiple values, use a table variable (@MyTable
) or a "regular" temporary table (#MyTempTable
)
这篇关于如何在SQL Server存储过程中声明整数数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!