91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

批量導出存儲在msdb庫的SSIS包

發布時間:2020-06-27 22:49:34 來源:網絡 閱讀:1613 作者:UltraSQL 欄目:數據庫

use msdb  
go


IF OBJECT_ID('msdb.dbo.usp_ExportSSISPkgs') IS NOT NULL  
  DROP PROCEDURE dbo.usp_ExportSSISPkgs;    
go


CREATE PROCEDURE dbo.usp_ExportSSISPkgs  
@exportPath NVARCHAR(2000)='D:\temp\'    
AS    
BEGIN

  DECLARE @pkgData XML, @pkgName NVARCHAR(1000),@pkgFolder NVARCHAR(4000), @cmd NVARCHAR(MAX) ;  
  PRINT '--Info: Create temp tables.';    
  IF (OBJECT_ID('tempdb.dbo.tbl_SSISPkgXML') IS NOT NULL)    
  BEGIN    
    PRINT '--Info: Drop existing temp table tempdb.dbo.tbl_SSISPkgXML.';    
    DROP TABLE tempdb.dbo.tbl_SSISPkgXML;    
  END    
  CREATE TABLE tempdb.dbo.tbl_SSISPkgXML(ID INT IDENTITY(1,1), PkgName NVARCHAR(1000) NULL, PkgFolder NVARCHAR(MAX) NULL,    
           PkgID VARCHAR(40) NULL,PkgData XML NULL);    
 

  PRINT '--Info: Insert Package data into tempdb.dbo.tbl_SSISPkgXML.';  
  IF (SELECT CHARINDEX('SQL Server 2005', @@VERSION))>0    
  --2005 version    
  BEGIN    
    --Use recursive CTE to get FULL path for SSIS packages on msdb    
    SET @cmd='WITH tbl_ssispkgfolder (FullPath, folderid)    
AS    
(SELECT CONVERT(NVARCHAR(MAX),''\root''),folderid FROM msdb.dbo.sysdtspackagefolders90    
  WHERE parentfolderid IS NULL    
  UNION ALL    
  SELECT CONVERT(NVARCHAR(MAX),t.FullPath+''\''+s.foldername),s.folderid    
  FROM msdb.dbo.sysdtspackagefolders90 s    
  JOIN tbl_ssispkgfolder t ON s.parentfolderid=t.folderid)    
    INSERT INTO tempdb.dbo.tbl_SSISPkgXML (PkgName,PkgID,PkgFolder,PkgData)    
      SELECT p.name, p.id, f.FullPath, CAST(CAST(packagedata AS varbinary(MAX)) AS XML)    
   FROM msdb.dbo.sysdtspackages90 p JOIN tbl_ssispkgfolder f ON p.folderid=f.folderid;';    
      EXEC(@cmd);    
  END    
  ELSE    
  --2008 or later version    
  BEGIN    
     SET @cmd='WITH tbl_ssispkgfolder (FullPath, folderid)    
AS    
(SELECT CONVERT(NVARCHAR(MAX),''\root''),folderid FROM msdb.dbo.sysssispackagefolders    
  WHERE parentfolderid IS NULL    
  UNION ALL    
  SELECT CONVERT(NVARCHAR(MAX),t.FullPath+''\''+s.foldername),s.folderid    
  FROM msdb.dbo.sysssispackagefolders s    
  JOIN tbl_ssispkgfolder t ON s.parentfolderid=t.folderid)    
    INSERT INTO tempdb.dbo.tbl_SSISPkgXML (PkgName,PkgID,PkgFolder,PkgData)    
      SELECT p.name, p.id, f.FullPath, CAST(CAST(packagedata AS varbinary(MAX)) AS XML)    
   FROM msdb.dbo.sysssispackages p JOIN tbl_ssispkgfolder f ON p.folderid=f.folderid    
      WHERE ISNULL(p.description,'''''''') NOT LIKE ''System Data Collector Package''    
      ;';    
      EXEC(@cmd);    
  END

  PRINT '--Info: Enable xp_cmdshell to allow access File System from SQL Engine';  
  EXEC sp_configure 'show advanced options',1;    
  RECONFIGURE WITH OVERRIDE;    
  EXEC sp_configure 'xp_cmdshell',1;    
  RECONFIGURE WITH OVERRIDE;

  PRINT '--Info: Start exporting...'  
  DECLARE cur_DtsxFile CURSOR FOR SELECT PkgName,PkgData, PkgFolder FROM tempdb.dbo.tbl_SSISPkgXML;    
  OPEN cur_DtsxFile;    
  FETCH NEXT FROM cur_DtsxFile INTO @pkgName, @pkgData, @pkgFolder;    
  WHILE (@@FETCH_STATUS=0)    
  BEGIN    
    PRINT '--Info: Create Package folder under '+@exportPath+ '';    
    SET @cmd= N'EXEC xp_cmdshell N''mkdir "' + @exportPath +@pkgFolder+ '\"''';    
    EXEC(@cmd);    
    SET @cmd=N'bcp "SELECT PkgData FROM tempdb.dbo.tbl_SSISPkgXML '    
   + 'WHERE PkgName=  '''''+@pkgName+''''' AND PkgFolder= '''''+@pkgFolder+'''''" queryout "'    
   + @exportPath+ @pkgFolder+ '\'+@pkgName+'.dtsx" -T -w -S"'+@@SERVERNAME+'"' ;    
    SET @cmd = N'EXEC xp_cmdshell N'''+@cmd +'''' ;    
    PRINT '--Info: Export package '+QUOTENAME(@pkgName)+' to ' + @exportPath +@pkgFolder+'';    
    EXEC(@cmd);    
    FETCH NEXT FROM cur_DtsxFile INTO @pkgName,@pkgData,@pkgFolder;    
  END    
  CLOSE cur_DtsxFile;    
  DEALLOCATE cur_DtsxFile;    

END



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

余姚市| 邵阳市| 布尔津县| 双峰县| 定结县| 邵阳县| 海林市| 宝坻区| 永顺县| 右玉县| 辉县市| 娄烦县| 唐河县| 银川市| 东乡| 余干县| 福海县| 兴和县| 沾化县| 孝昌县| 长汀县| 孝感市| 崇明县| 即墨市| 姜堰市| 阿合奇县| 辛集市| 乌鲁木齐市| 平原县| 赤峰市| 晋宁县| 汝城县| 玛沁县| 濮阳县| 麻江县| 文登市| 安龙县| 勃利县| 茶陵县| 聂荣县| 石柱|