表如下
id arg1 arg2 arg3 com reslut
1 1 2 3 @[email protected] 3
arg1-arg3是参数
com 是表达式
代码如下
declare @in_arg1 as int,@in_arg2 int ,@in_arg3 int
select @in_arg1 =arg1 ,@in_arg2=arg2 ,@in_arg1=arg3 from com where id =1;
declare @sql nvarchar(4000)
set @sql='select com from com where id=1; ';
exec sp_executesql
@[email protected],
@params = [email protected] as int,@arg2 as int ,@arg3 as int,@result int output',
@[email protected]_arg1 ,
@[email protected]_arg2,
@[email protected]_arg3
错误
总是提示
消息 102,级别 15,状态 1,第 9 行
[email protected] as int,@arg2 as int ,@arg3 as int,@result int output' 附近有语法错误。
无法解决啊!!!
不好意思分很少了一点心意!!
------解决方案--------------------
declare @in_arg1 as int,@in_arg2 int ,@in_arg3 int,@result int
select @in_arg1 =arg1 ,@in_arg2=arg2 ,@in_arg1=arg3 from com where id =1;
declare @sql nvarchar(4000)
select @sql='select @result='+com from com where id=1;
exec sp_executesql
@[email protected],
@params = [email protected] as int,@arg2 as int ,@arg3 as int,@result int output',
@[email protected]_arg1 ,
@[email protected]_arg2,
@[email protected]_arg3,
@[email protected] output
select @result