Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Перенос DTS пакетов на другой сервер / 2 сообщений из 2, страница 1 из 1
05.11.2002, 11:44:25
    #32064891
Дмитрий  (GS)
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Перенос DTS пакетов на другой сервер
День добрый.

Кто подскажет самый эффективный путь для переноса созданных DTS пакетов с одного сервера на другой. Используется MS SQL Server 2000.

Спасибо,
Дмитрий
...
Рейтинг: 0 / 0
05.11.2002, 12:05:55
    #32064902
snake
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Перенос DTS пакетов на другой сервер
Вот один из варантов:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
 /*
Процедура загружает\выгружает 
DTSPackage с\на сервера\сервер в\из
указанную\ой дирректорию\ии
*/ 
ALTER          PROCEDURE sp_LoadSaveDTSPackage
	@dirname varchar( 256 ) = null,
	@isin bit 
as
	set nocount on
	declare @SQL varchar( 256 ),
			@result int,
			@oPKG int,
			@dtsname varchar( 256 ),
			@LoadStr varchar( 256 ),
			@src varchar( 255 ), 
			@desc varchar( 255 )

	if @dirname  is not null begin 
		create table #dts (dtsname varchar( 256 ))
		if @isin =  1  begin
			set @SQL = 'dir '+@dirname+'\*.dts'

			insert into #dts exec @result = master..xp_cmdshell @SQL
			if (@result !=  0 ) begin
				raiserror ('Не могу прочесть файлы!',  16 ,  1 )
				return(- 1 )
			end
			delete from #dts where isnumeric(substring(dtsname, 1 , 1 )) =  0  
			update #dts set dtsname = reverse(left(reverse(dtsname),charindex(' ',reverse(dtsname))- 1 ))

		end
		else begin
			insert into #dts select distinct name from msdb..sysdtspackages
		end
		declare dts cursor for
			select dtsname from #dts 
		open dts
		fetch next from dts
		into @dtsname
		while @@fetch_status =  0  begin

			exec @result = sp_OACreate 'DTS.Package', @oPKG OUT
			if @result <>  0 	begin
			   exec sp_OAGetErrorInfo @oPKG, @src OUT, @desc OUT 
			   select hr=convert(varbinary( 4 ),@result), Source=@src, description=@desc
			   return (- 1 )
			end

			if @isin !=  1  begin
				set @LoadStr = 'LoadFromSQLServer ("'+@@servername+'",,,256,,,,"'+@dtsname+'")'
				exec @result = sp_OAMethod @oPKG,@LoadStr
				if @result <>  0 	begin
				   exec sp_OAGetErrorInfo @oPKG, @src OUT, @desc OUT 
				   select hr=convert(varbinary( 4 ),@result), Source=@src, description=@desc
				   return (- 1 )
				end
				set @LoadStr = 'SaveToStorageFile ("'+@dirname+'\'+@dtsname+'.dts")'
				exec @result = sp_OAMethod @oPKG,@LoadStr
				if @result <>  0 	begin
				   exec sp_OAGetErrorInfo @oPKG, @src OUT, @desc OUT 
				   select hr=convert(varbinary( 4 ),@result), Source=@src, description=@desc
				   return (- 1 )
				end
			end
			else begin
				set @LoadStr = 'LoadFromStorageFile ("'+@dirname+'\'+@dtsname+'","")'
				exec @result = sp_OAMethod @oPKG,@LoadStr
				if @result <>  0 	begin
				   exec sp_OAGetErrorInfo @oPKG, @src OUT, @desc OUT 
				   select hr=convert(varbinary( 4 ),@result), Source=@src, description=@desc
				   return (- 1 )
				end
				set @LoadStr = 'SaveToSQLServer ("'+@@servername+'",,,256)'
				exec @result = sp_OAMethod @oPKG,@LoadStr
				if @result <>  0 	begin
				   exec sp_OAGetErrorInfo @oPKG, @src OUT, @desc OUT 
				   select hr=convert(varbinary( 4 ),@result), Source=@src, description=@desc
				   return (- 1 )
				end
			end
			exec @result = sp_OADestroy @oPKG
			if @result <>  0 	begin
			   exec sp_OAGetErrorInfo @oPKG
			   return (- 1 )
			end

			fetch next from dts
			into @dtsname
		end
		close dts
		deallocate dts
	end
	else begin 
		return (- 1 )
	end
	set nocount off

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
...
Рейтинг: 0 / 0
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Перенос DTS пакетов на другой сервер / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]