日期:2014-05-18 浏览次数:20614 次
declare @i int set @i=400001 while @i < 400003 begin declare @tbname varchar(50) declare @sql varchar(255) set @tbname = 'Min50' + RTRIM(@i) set @sql = 'select * from ' + @tbname + ' where Volumn != 0' exec(@sql) set @i = @i + 1 end
------解决方案--------------------
/****** Script for SelectTopNRows command from SSMS ******/ declare @i int set @i=400001 while @i < 400003 begin declare @tbname varchar(12) declare @sql varchar(255) set @tbname = 'Min50' + convert(varchar(6),@i) set @sql = 'select * from ' + @tbname + ' where Volumn != 0' exec(@sql) set @i = @i + 1 end