sql 动态语句
sql语句:
declare @all int,@num int, @sqls nvarchar(100),@str nvarchar(100)
set @sqls='select distinct sho_id from view_ocs '
set @str ='select @a=count(*) from view_ocs'
exec sp_executesql @str,N'@a int output',@num output
select @num
exec sp_executesql @sqls,N'@sho_id int output',@all output
结果:
就是我想根据索引值取数组中的数据!
------解决方案--------------------没看懂,请问LZ希望的结果是什么.
------解决方案--------------------可以考虑一下for循环
for i in a loop
end loop;