Last active
December 17, 2015 21:49
-
-
Save mbourgon/5677862 to your computer and use it in GitHub Desktop.
Parse the ConnectionString information out of SSIS packages stored in MSDB on 2008/R2/2012. SSISDB will have to be handled differently.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @DTS_Packages TABLE | |
( | |
PackageName SYSNAME, | |
PackageDescription SYSNAME, | |
Creator SYSNAME, | |
CreateDate DATETIME, | |
PackageXML XML | |
) | |
INSERT INTO @DTS_Packages | |
SELECT p.[name] AS [PackageName], | |
[description] AS [PackageDescription], | |
l.[name] AS [Creator], | |
p.[createdate], | |
CAST(CAST(packagedata AS VARBINARY(MAX)) AS XML) PackageXML | |
FROM [msdb].[dbo].[sysssispackages] p | |
JOIN sys.syslogins l | |
ON p.[ownersid] = l.[sid]; | |
--you either need ;WITH or the previous statement needs the semicolon for the | |
--WITH NAMESPACE... which precludes a CTE | |
WITH XMLNAMESPACES ('www.microsoft.com/SqlServer/Dts' AS dts) | |
SELECT [@DTS_Packages].PackageName, | |
[@DTS_Packages].PackageDescription, | |
[@DTS_Packages].Creator, | |
[@DTS_Packages].CreateDate, | |
[@DTS_Packages].PackageXML, | |
Con.Str.value('.', 'varchar(500)') --aka give me that exact node | |
FROM @DTS_Packages | |
CROSS APPLY PackageXML.nodes('//dts:Property[@dts:Name="ConnectionString"]') AS Con(Str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment