我可以发送参数数组来存储过程吗? [英] Can I send array of parameter to store procedure?
问题描述
我有User
表,它具有UserId uniqueidentifier
,名称varchar
和IsActive bit
.
I have User
table, it has UserId uniqueidentifier
, Name varchar
and IsActive bit
.
我想创建将许多用户的IsActive设置为false的存储过程,例如,如果要停用2个用户,则要发送这些用户的Guid
来存储过程(最好是数组).我想知道该怎么办?
I want to create store procedure to set IsActive to false for many user, for example, if I want to deactive 2 users, I want to send Guid
of those users to store procedure (prefer as array). I want to know how can I do it?
P.S.我正在使用Microsoft SQL Azure
P.S. I'm working on Microsoft SQL Azure
推荐答案
与Elian相同,所以请看一下XML参数.一般来说,与解析字符串列表相比,您应该使用xml来实现更简洁/安全的实现. 点击此处查看代码示例
Along the same lines than Elian, take a look at XML parameters. Generally speaking you should have a cleaner/safer implementation using xml than parsing a list of strings. Click here for a code example
这篇关于我可以发送参数数组来存储过程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!