alter PROC sp_writeall ( @dirpath varchar(1024),@filetype varchar(255) = '.sql' )
as
declare @sql varchar(4000),@sql2 varchar(4000) ='' ,@count int ;
set @sql = 'dir '+ @dirpath + ' /b/a ' ;
create table #temp ( dirfile nvarchar(255)) ;
insert into #temp
exec xp_cmdshell @sql ;
select @count = COUNT(1) from #temp
where dirfile like '%' + @filetype ;
select @sql2 = @sql2 + ' exec xp_cmdshell ' + ''' type ' + @dirpath + '\' + dirfile +' >> '+ @dirpath + '\' + CAST( @count as varchar)+'_all.sql' +''''+ char(13) + char(10)
from #temp
where dirfile like '%' + @filetype ;
print @sql2;
exec ( @sql2 ) ;
drop table #temp;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)