Skip to content

Instantly share code, notes, and snippets.

@niktho
Last active February 26, 2019 22:01
Show Gist options
  • Save niktho/0f8e7f6773b8e3b377b02253630b07aa to your computer and use it in GitHub Desktop.
Save niktho/0f8e7f6773b8e3b377b02253630b07aa to your computer and use it in GitHub Desktop.
$connectionString = "<ADD YOUR CONNECTION STRING HERE>"
$sqlCommand = 'BEGIN TRY EXEC tSQLt.RunAll END TRY BEGIN CATCH END CATCH; EXEC tSQLt.XmlResultFormatter'
$connection = new-object system.data.SqlClient.SQLConnection($connectionString)
$command = new-object system.data.sqlclient.sqlcommand($sqlCommand,$connection)
$connection.Open()
$adapter = New-Object System.Data.sqlclient.sqlDataAdapter $command
$dataset = New-Object System.Data.DataSet
$adapter.Fill($dataSet) | Out-Null
$connection.Close()
$dataSet.Tables[0].Rows[0].ItemArray[0] | Out-File "$(System.DefaultWorkingDirectory)/_ndev-db-CI/drop/azure-sql-database/TEST-ndevdb.xml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment