22,298
社区成员
发帖
与我相关
我的任务
分享set @tmp=N'select @maxid=max('+@tableidname+') from '+@tablename
exec sp_executesql @tmp,N'@maxid varchar(50) output',@maxid varchar(50)set @tmp=exec('select max('+@tableidname+') from '+@tablename) 输出参数
declare @num int, @sqls nvarchar(4000)
set @sqls='select count(*) from tableName'
exec(@sqls)
--如何将exec执行结果放入变量中?
declare @num int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName '
exec sp_executesql @sqls,N'@a int output',@num output
select @num