Skip to content

Commit

Permalink
0.9.790
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Mar 18, 2019
1 parent d8543d3 commit dcda3dc
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 2 deletions.
111 changes: 109 additions & 2 deletions allcommands.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16824,6 +16824,113 @@ function Export-DbaDacPackage {
Test-DbaDeprecation -DeprecatedOn "1.0.0" -EnableException:$false -Alias Export-DbaDacpac
}
}
#ValidationTags#Messaging,FlowControl,Pipeline,CodeStyle#
function Export-DbaDbTableData {
<#
.SYNOPSIS
Exports data from tables

.DESCRIPTION
Exports data from tables

.PARAMETER InputObject
Pipeline input from Get-DbaDbTable

.PARAMETER Path
The output filename and location. If no path is specified, one will be created. If the file already exists, the output will be appended.

.PARAMETER Encoding
Specifies the file encoding. The default is UTF8.

Valid values are:
-- ASCII: Uses the encoding for the ASCII (7-bit) character set.
-- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order.
-- Byte: Encodes a set of characters into a sequence of bytes.
-- String: Uses the encoding type for a string.
-- Unicode: Encodes in UTF-16 format using the little-endian byte order.
-- UTF7: Encodes in UTF-7 format.
-- UTF8: Encodes in UTF-8 format.
-- Unknown: The encoding type is unknown or invalid. The data can be treated as binary.

.PARAMETER Passthru
Output script to console

.PARAMETER BatchSeparator
Specifies the Batch Separator to use. Default is None

.PARAMETER NoPrefix
Do not include a Prefix

.PARAMETER NoClobber
Do not overwrite file

.PARAMETER Append
Append to file

.PARAMETER WhatIf
Shows what would happen if the command were to run. No actions are actually performed

.PARAMETER Confirm
Prompts you for confirmation before executing any changing operations within the command

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

.NOTES
Tags: Migration, Backup, Export
Author: Chrissy LeMaire (@cl), netnerds.net

Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT

.LINK
https://dbatools.io/Export-DbaDbTableData

.EXAMPLE
PS C:\> Get-DbaDbTable -SqlInstance sql2017 -Database AdventureWorks2014 -Table EmployeePayHistory | Export-DbaDbTableData

Exports data from EmployeePayHistory in AdventureWorks2014 in sql2017

.EXAMPLE
PS C:\> Get-DbaDbTable -SqlInstance sql2017 -Database AdventureWorks2014 -Table EmployeePayHistory | Export-DbaDbTableData -Path C:\temp\export.sql -Append

Exports data from EmployeePayHistory in AdventureWorks2014 in sql2017 using a trusted connection - Will append the output to the file C:\temp\export.sql if it already exists
Script does not include Batch Separator and will not compile

.EXAMPLE
PS C:\> Get-DbaDbTable -SqlInstance sql2016 -Database MyDatabase -Table 'dbo.Table1', 'dbo.Table2' -SqlCredential sqladmin | Export-DbaDbTableData -Path C:\temp\export.sql

Exports only data from 'dbo.Table1' and 'dbo.Table2' in MyDatabase to C:temp\export.sql and uses the SQL login "sqladmin" to login to sql2016
#>
[CmdletBinding(SupportsShouldProcess)]
param (
[parameter(Mandatory, ValueFromPipeline)]
[Microsoft.SqlServer.Management.Smo.Table[]]$InputObject,
[string]$Path,
[ValidateSet('ASCII', 'BigEndianUnicode', 'Byte', 'String', 'Unicode', 'UTF7', 'UTF8', 'Unknown')]
[string]$Encoding = 'UTF8',
[string]$BatchSeparator = '',
[switch]$NoPrefix,
[switch]$Passthru,
[switch]$NoClobber,
[switch]$Append,
[switch]$EnableException
)

begin {
$ScriptingOptionsObject = New-DbaScriptingOption
$ScriptingOptionsObject.ScriptSchema = $false
$ScriptingOptionsObject.ScriptData = $true
$ScriptingOptionsObject.IncludeDatabaseContext = $true
}

process {
Export-DbaScript @PSBoundParameters -ScriptingOptionsObject $ScriptingOptionsObject
}
}
function Export-DbaDiagnosticQuery {
<#
.SYNOPSIS
Expand Down Expand Up @@ -92661,7 +92768,7 @@ function Start-DbaAgentJob {
# Wait for the job
if (Test-Bound -ParameterName Wait) {
while ($currentjob.CurrentRunStatus -ne 'Idle') {
Write-Message -Level Output -Message "$currentjob is $($currentjob.CurrentRunStatus)"
Write-Message -Level Verbose -Message "$currentjob is $($currentjob.CurrentRunStatus)"
Start-Sleep -Seconds $WaitPeriod
$currentjob.Refresh()
}
Expand Down Expand Up @@ -94041,7 +94148,7 @@ function Stop-DbaAgentJob {

if ($wait) {
while ($currentjob.CurrentRunStatus -ne 'Idle') {
Write-Message -Level Output -Message "$currentjob is $($currentjob.CurrentRunStatus)"
Write-Message -Level Verbose -Message "$currentjob is $($currentjob.CurrentRunStatus)"
Start-Sleep -Seconds 3
$currentjob.Refresh()
}
Expand Down
107 changes: 107 additions & 0 deletions bin/dbatools-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6298,6 +6298,113 @@
],
"Syntax": "Export-DbaDacPackage -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllUserDatabases] [-Path \u003cString\u003e] [-DacOption \u003cObject\u003e] [-Type \u003cString\u003e] [-Table \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nExport-DbaDacPackage -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllUserDatabases] [-Path \u003cString\u003e] [-ExtendedParameters \u003cString\u003e] [-ExtendedProperties \u003cString\u003e] [-Type \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]"
},
{
"Name": "Export-DbaDbTableData",
"Description": "Exports data from tables",
"Tags": [
"Migration",
"Backup",
"Export"
],
"Synopsis": "Exports data from tables",
"Alias": "",
"Author": "Chrissy LeMaire (@cl), netnerds.net",
"CommandName": "Export-DbaDbTableData",
"Availability": "Windows, Linux, macOS",
"Links": "https://dbatools.io/Export-DbaDbTableData",
"Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql2017 -Database AdventureWorks2014 -Table EmployeePayHistory | Export-DbaDbTableData\nExports data from EmployeePayHistory in AdventureWorks2014 in sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql2017 -Database AdventureWorks2014 -Table EmployeePayHistory | Export-DbaDbTableData -Path C:\\temp\\export.sql -Append\nExports data from EmployeePayHistory in AdventureWorks2014 in sql2017 using a trusted connection - Will append the output to the file C:\\temp\\export.sql if it already exists\r\nScript does not include Batch Separator and will not compile\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql2016 -Database MyDatabase -Table \u0027dbo.Table1\u0027, \u0027dbo.Table2\u0027 -SqlCredential sqladmin | Export-DbaDbTableData -Path C:\\temp\\export.sql\nExports only data from \u0027dbo.Table1\u0027 and \u0027dbo.Table2\u0027 in MyDatabase to C:temp\\export.sql and uses the SQL login \"sqladmin\" to login to sql2016",
"Params": [
[
"InputObject",
"Pipeline input from Get-DbaDbTable",
"",
true,
"true (ByValue)",
""
],
[
"Path",
"The output filename and location. If no path is specified, one will be created. If the file already exists, the output will be appended.",
"",
false,
"false",
""
],
[
"Encoding",
"Specifies the file encoding. The default is UTF8.\nValid values are:\r\n-- ASCII: Uses the encoding for the ASCII (7-bit) character set.\r\n-- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order.\r\n-- Byte: Encodes a set of characters into a sequence of bytes.\r\n-- String: Uses the encoding type for a string.\r\n-- Unicode: Encodes in UTF-16 format using the little-endian byte order.\r\n-- UTF7: Encodes in UTF-7 format.\r\n-- UTF8: Encodes in UTF-8 format.\r\n-- Unknown: The encoding type is unknown or invalid. The data can be treated as binary.",
"",
false,
"false",
"UTF8"
],
[
"BatchSeparator",
"Specifies the Batch Separator to use. Default is None",
"",
false,
"false",
""
],
[
"NoPrefix",
"Do not include a Prefix",
"",
false,
"false",
"False"
],
[
"Passthru",
"Output script to console",
"",
false,
"false",
"False"
],
[
"NoClobber",
"Do not overwrite file",
"",
false,
"false",
"False"
],
[
"Append",
"Append to file",
"",
false,
"false",
"False"
],
[
"EnableException",
"By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.",
"",
false,
"false",
"False"
],
[
"WhatIf",
"Shows what would happen if the command were to run. No actions are actually performed",
"wi",
false,
"false",
""
],
[
"Confirm",
"Prompts you for confirmation before executing any changing operations within the command",
"cf",
false,
"false",
""
]
],
"Syntax": "Export-DbaDbTableData [-InputObject] \u003cTable[]\u003e [[-Path] \u003cString\u003e] [[-Encoding] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [-NoPrefix] [-Passthru] [-NoClobber] [-Append] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]"
},
{
"Name": "Export-DbaDiagnosticQuery",
"Description": "The default output format of Invoke-DbaDiagnosticQuery is a custom object. It can also output to CSV and Excel.\nHowever, CSV output can generate a lot of files and Excel output depends on the ImportExcel module by Doug Finke (https://github.com/dfinke/ImportExcel)\nExport-DbaDiagnosticQuery can be used to convert from the default export type to the other available export types.",
Expand Down

0 comments on commit dcda3dc

Please sign in to comment.