SqlBulkCopy-Table

SqlBulkCopy-Table
NAME
    SqlBulkCopy-Table
    
SYNOPSIS
    Copy table from Source to Destination.
    
    
SYNTAX
    SqlBulkCopy-Table [-SourceDataSource] <String> [-DestinationDataSource] <String> [-SourceTable] <String> [[-DestinationTable] <String>] [[-BulkCopyBatchSize] 
    <Int32>] [[-BulkCopyTimeoutSeconds] <Int32>] [[-BulkCopyStreaming] <Boolean>] [[-ConnectionTimeout] <Int32>] [<CommonParameters>]
    
    
DESCRIPTION
    Copy table between Source and Destination with SQLBulkCopy Class. If destination table does not exists then it will be automatically created based on informat
    ion
    gathered from source table columns properties. 
    
    If destination table exists it will be truncated before importing source data to prevent doubled data.
    

PARAMETERS
    -SourceDataSource <String>
        
        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -DestinationDataSource <String>
        
        Required?                    true
        Position?                    2
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -SourceTable <String>
        
        Required?                    true
        Position?                    3
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -DestinationTable <String>
        
        Required?                    false
        Position?                    4
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -BulkCopyBatchSize <Int32>
        
        Required?                    false
        Position?                    5
        Default value                1000 rows
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -BulkCopyTimeoutSeconds <Int32>
        
        Required?                    false
        Position?                    6
        Default value                120 seconds
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -BulkCopyStreaming <Boolean>
        
        Required?                    false
        Position?                    7
        Default value                True
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -ConnectionTimeout <Int32>
        
        Required?                    false
        Position?                    8
        Default value                120 seconds
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see 
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). 
    
INPUTS
    System.Int64
    System.Int32
    System.String
    System.Boolean
    
    
OUTPUTS
    
NOTES
    
    
        Author : Sebastian Ziółkowski
        Website: ziolkowsky.wordpress.com
        GitHub : github.com/ziolkowsky
    
    -------------------------- EXAMPLE 1 --------------------------
    
    PS>SqlBulkCopy-Table -SourceDataSource 'server1\SQLEXPRESS' -DestinationDataSource 'server2\SQLEXPRESS' -SourceTable 'catalog.dbo.Table' -DestinationTable 'ca
    talog.dbo.Table'
    
    Copy table to identical structure at other db server. The same effect can be done without -DestinationTable parameter:
    
    PS> SqlBulkCopy-Table -SourceDataSource 'server1\SQLEXPRESS' -DestinationDataSource 'server2\SQLEXPRESS' -SourceTable 'catalog.dbo.Table'
    
    
    
    
    -------------------------- EXAMPLE 2 --------------------------
    
    PS>SqlBulkCopy-Table -SourceDataSource 'server1\SQLEXPRESS' -DestinationDataSource 'server2\SQLEXPRESS' -SourceTable 'catalog.dbo.Table' -DestinationTable 'ca
    talog1.dbo.Table2'
    
    Copy table to different server, catalog and table.
    
    
    
    
    -------------------------- EXAMPLE 3 --------------------------
    
    PS>SqlBulkCopy-Table -SourceDataSource 'server1\SQLEXPRESS' -DestinationDataSource 'server2\SQLEXPRESS' -SourceTable 'catalog.dbo.Table' -BulkCopyBatchSize 10
    000 -BulkCopyTimeoutSeconds 120 -BulkCopyStreaming $true
    
    
    
    
    
    
    
RELATED LINKS
    https://ziolkowsky.wordpress.com/2022/05/08/powershell-copy-mssql-table-between-different-db-instances/
    https://github.com/ziolkowsky/ShellPowerFramework

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.

*