日期:2014-05-18 浏览次数:20493 次
declare @tbnumber int declare @tbname varchar(10) declare @str varchar(1000) select @tbnumber=convert(int,ceiling(rand()*5)) set @tbname='a'+convert(varchar(10),@tbnumber) set @str=N'select * from '+@tbname exec sp_executesql @str
------解决方案--------------------
declare @tbnumber int
declare @tbname varchar(10)---------declare @tbname nvarchar(10)
declare @str varchar(1000)---------declare @str nvarchar(1000)
select @tbnumber=convert(int,ceiling(rand()*5))
set @tbname='a'+convert(varchar(10),@tbnumber)
set @str=N'select * from '+@tbname
exec sp_executesql @str
上面对应修改即可``