当前位置: 代码迷 >> Sql Server >> 问一个动态执行存储过程有关问题
  详细解决方案

问一个动态执行存储过程有关问题

热度:69   发布时间:2016-04-27 21:05:25.0
问一个动态执行存储过程问题
有这么一个存储过程
_Action_UserType
@UserID   int,
@Cooperaters   nvarchar(128),
@TypeFlag   int,
@Code   int   out

这个存储过程的执行条件是存在数据库中的就是我数据库中存放
'exec   _Action_UserType   111, ' 'xx,yy ' ',1,@Code '
这么一个字符串
现在我用
declare   @ExecSQL   nvarchar(512);
declare   @AllNum   int;
set   @ExecSQL   =   'exec   _Action_UserType   111, ' '@TM,@WL ' ',1,@Code ';
exec   sp_executesql   @ExecSQL,N '@Code   int   output ',@AllNum;
print   @AllNum
这样来执行,判断是否满足条件
[email protected][email protected]
有高人指点下么?我要怎么得到_Action_UserType   存储过程里面得输出内容。


------解决方案--------------------
declare @ExecSQL nvarchar(512)
declare @AllNum int
set @ExecSQL = 'exec _Action_UserType 111, ' '@TM,@WL ' ',1,@Code out ' --这里再增加一个out
exec sp_executesql @ExecSQL,N '@Code int output ',@AllNum output
print @AllNum
  相关解决方案