Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
declare @hr int
,@dts int
,@src int
,@dataSource varchar(50)
,@SrcFolder varchar(255)
,@buffer nvarchar(4000)
,@object int
create Table #tFiles
(FileName varchar(100))
set @SrcFolder = 'c:\folder\source'
--get files in the import folder
set @buffer = 'dir ' + @SrcFolder + ' /B'
insert into #tFiles
exec master..xp_CMDShell @buffer
delete from #tFiles where len(IsNull(FileName,'')) < 1
exec @hr = sp_OACreate 'DTS.Package', @dts out
if @hr <> 0 begin set @object = @dts goto abt end
exec @hr = sp_OAMethod @dts, 'LoadFromSQLServer',NULL, @ServerName = @@SERVERNAME,
@PackageName = 'YOURDTSNAME', @Flags = 256
if @hr <> 0 begin set @object = @dts goto abt end
exec @hr = sp_OAGetProperty @dts, 'connections("src")', @src out
if @hr <> 0 begin set @object = @dts goto abt end
if right(rtrim(@SrcFolder),1) <> '\'
set @SrcFolder = @SrcFolder + '\'
--clear old data
delete from dbo.tmpMotorIntelligenceStage
--for each file import data
while exists(select 1 from #tFiles)
begin
select top 1 @buffer = FileName from #tFiles
delete from #tFiles where FileName = @buffer
select @buffer = @SrcFolder + @buffer
exec @hr = sp_OASetProperty @src, 'datasource', @buffer
exec @hr = sp_Oamethod @dts, 'execute'
end
goto EXT
ABT:
exec sp_OAGetErrorInfo @object
EXT:
exec @hr = sp_OADestroy @src
exec @hr = sp_OADestroy @dts
drop table #tFiles