Last active
September 26, 2017 02:39
-
-
Save bseebacher/b20c30e401ba8c5aeceb00d61172f690 to your computer and use it in GitHub Desktop.
Example of writing varbinary(MAX) return of [catalog].[get_project] to file.
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
$cmdExport = New-Object System.Data.SqlClient.SqlCommand | |
$cmdExport.Connection = $catalogDbConnection # Open connection to SSISDB | |
$cmdExport.CommandText = "[catalog].[get_project]" | |
$cmdExport.Parameters.AddWithValue("@folder", "<your SSIS Folder Name>") | Out-Null | |
$cmdExport.Parameters.AddWithValue("@project", "<your SSIS Project Name") | Out-Null | |
# Use ExecuteScalar() method to get a cursor to read varbinary(MAX) return. | |
$bReader = $sqlCommand.ExecuteScalar() | |
# WRITING OUTPUT | |
# Use the WriteAllBytes static method on the .NET System.IO.File class | |
# for writing bytes to disk at provided path. | |
# Cast varbinary(MAX) query return to byte[] array to use as function argument. | |
[System.IO.File]::WriteAllBytes("SsisPackage.zip", [byte[]]$bReader) | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment