exec sp_prepexec 问题
declare @p1 int
exec sp_prepexec @p1 output,N'@P0 nvarchar(4000)',N'delete from [login] where [empid] in (@P0)',
N'20102820'
成功
declare @p1 int
exec sp_prepexec @p1 output,N'@P0 nvarchar(4000)',N'delete from [login] where [empid] in (@P0)',
N'20102832,20102820,20102821'
失败
为什么@P0 参数变成'20102832,20102820,20102821' 就执行不成功啊??
[解决办法]
多个id组合,应该这样写:
declare @p1 int
exec sp_prepexec @p1 output,N'@P0 nvarchar(4000)',N'delete from [login] where charindex('',''+cast(empid as varchar)+'','','',''+@P0+'','')>0',
N'20102832,20102820,20102821'