Search Documentation by Keyword

Export-CsvTestData

You are here:
← All Topics

Generates a CSV file of random test data matching the schema of a designated database table.

Columns may be included or excluded based on a regex pattern. Values may be constrained into ranges by type.

Character data will be generated as random sequences of capital letters, to the column length limit or to the value of -MaxStrLen, whichever is smaller.

Syntax

Export-CsvTestData `
    [-DbServer <string>] `
    [-DbName <string>] `
    [-TableSchema <string>] `
    -TableName <string> `
    [-ColNameAction <Include|Exclude>] `
    [-ColNamePattern <string>] `
    -CsvPath <string>] `
    [-RowCount <int>] `
    [-MinDate <datetime>] `
    [-MaxDate <datetime>] `
    [-MinDec <decimal>] `
    [-MaxDec <decimal>] `
    [-MinInt <int>] `
    [-MaxInt <int>] `
    [-MaxStrLen <int>]

Parameters

ParameterRDescription
DbServerThe target SQL Server database server address.

Default: $Global:MedmDbServer

Example: -DbServer "MyDbServer"
DbNameThe target SQL Server database name.

Default: $Global:MedmDbName

Example: -DbName "MyDb"
TableSchemaSchema of the target database table.

Default: "dbo"

Example: -TableSchema "dbo"
TableName*Target database table name.

Example: -TableName "T_MASTER_SEC"
ColNameActionIndicates whether -ColNamePattern will be used to include or exclude columns. Valid values: Include, Exclude

Default: Exclude

Example: -ColNameAction Exclude
ColNamePatternRegex pattern of column names to include or exclude.

Default: "^CADIS_SYSTEM_|.*RUN_?ID"

Example: -ColNamePattern "^CADIS_SYSTEM\_.\*RUN\_?ID"
CsvPath*The path to the CSV file to be generated. Relative paths will be resolved relative to the script execution path.

Example: -CsvPath "./SetupSql/T_MASTER_SEC.csv"
RowCountNumber of rows of test data to generate.

Default: 10

Example: -RowCount 10
MinDateMinimum value for randomly generated date-type values.

Default: 2018-01-01T00:00:00

Example: -MinDate [datetime]::ParseExact("2018-01-01", "yyyy-MM-dd", $null)
MaxDateMaximum value for randomly generated date-type values.

Default: 2028-01-01T00:00:00

Example: -MaxDate [datetime]::ParseExact("2028-01-01", "yyyy-MM-dd", $null)
MinDecMinimum value for randomly generated decimal-type values.

Default: 0

Example: -MinDec 0.0
MaxDecMaximum value for randomly generated decimal-type values.

Default: 10.0

Example: -MaxDec 10.0
MinIntMinimum value for randomly generated integer-type values.

Default: 0

Example: -MinInt 0.0
MaxIntMaximum value for randomly generated integer-type values.

Default: 10

Example: -MaxInt 10.0
MaxStrLenMaximum length of generated character strings.

Default: 32

Example: -MaxStrLen 32
×