< Back

Export-DataTable

Tue Jan 14, 2020 1:23 am

NAME Export-DataTable



SYNOPSIS

Inserts objects into a database table.





SYNTAX

Export-DataTable [-FileOrName] <string> [-TableName] <string> [[-AdditionalColumns] <string[]>] [[-TypeName]

<string>] [-InputObject <object>] [<CommonParameters>]



Export-DataTable [-Connection] <DbConnection> [-TableName] <string> [[-AdditionalColumns] <string[]>] [[-TypeName]

<string>] [-InputObject <object>] [<CommonParameters>]





DESCRIPTION

The Export-DataTable cmdlet inserts objects from the pipeline into a database table specified by the -TableName

parameter.



The properties of the objects are mapped to the database columns with the same names. If there are no

corresponding columns in the table, such properties are ignored.



If the specified table does not exist, the cmdlet will create a new table based on the structure of the given

object. In the current version, all columns are defined as string type. This does not matter because most database

engines allow to apply arithmetic operations to string columns. If you need a table with exact types, create a

table manually by the Invoke-DataQuery cmdlet before exporting.





PARAMETERS

-InputObject <object>

Objects to be inserted into a database table.



Required? false

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-FileOrName <string>

A database file name or a connection string name.



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Connection <DbConnection>

A database connection.



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-TableName <string>

A table name into which objects will be inserted. The value is embeded without being quoted into SQL

statements that the cmdlet generates internally.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-AdditionalColumns <string[]>

Additional column names.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-TypeName <string>

A type of columns of a newly created table. By default, it is one of 'varchar' (general databases), 'nvarchar'

(SQL Server), 'varchar2' (Oracle), or an empty string (SQLite).



Required? false

Position? 3

Default value

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.Object

Objects to be inserted into a database table.





OUTPUTS

None







RELATED LINKS