New-DecimalColumn

Creates a column object representing a decimal data type.

Syntax

New-DecimalColumn [-Name] <String> [[-Precision] <Int32>] [[-Scale] <Int32>] [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-DecimalColumn [-Name] <String> [[-Precision] <Int32>] [[-Scale] <Int32>] -Identity [-Seed <Int32>] [-Increment <Int32>] [-NotForReplication] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-DecimalColumn [-Name] <String> [[-Precision] <Int32>] [[-Scale] <Int32>] -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]

Description

Use this function in the Column script block for Add-Table:

Add-Table 'Items' {
    Decimal 'Price'
}

ALIASES

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The column's name.

true false
Precision Int32

Maximum total number of decimal digits that will be stored.

false false 0
Scale Int32

The number of decimal digits that will be stored to the right of the decimal point.

false false 0
Identity SwitchParameter

The column should be an identity.

true false False
Seed Int32

The starting value for the identity.

false false 0
Increment Int32

The increment between auto-generated identity values.

false false 0
NotForReplication SwitchParameter

Stops the identity from being replicated.

false false False
NotNull SwitchParameter

Don't allow NULL values in this column.

true false False
Sparse SwitchParameter

Store nulls as Sparse.

false false False
Default String

A SQL Server expression for the column's default value

false false
Description String

A description of the column.

false false

EXAMPLE 1

Add-Table 'Items' { Decimal 'Price' 5 2 }

Demonstrates how to create an optional decimal column called Price, with a five-digit precision (prices less than $999.99) and a scale of 2 (2 digits after the decimal).

EXAMPLE 2

Add-Table 'Items' { Decimal 'Price' -Identity -Seed 1 -Increment 1 }

Demonstrates how to create a required decimal column called Price, which is used as the table's identity. The identity values will start at 1, and increment by 1. Uses SQL Server's default precision/scale.

EXAMPLE 3

Add-Table 'Items' { Decimal 'Price' -NotNull }

Demonstrates how to create a required decimal column called Price. Uses SQL Server's default precision/scale.

EXAMPLE 4

Add-Table 'Items' { Decimal 'Price' -Sparse }

Demonstrates how to create a sparse, optional decimal column called Price. Uses SQL Server's default precision/scale.

EXAMPLE 5

Add-Table 'Items' { Decimal 'Price' -NotNull -Default '0' }

Demonstrates how to create a required decimal column called Price with a default value of 0. Uses SQL Server's default precision/scale.

EXAMPLE 6

Add-Table 'Items' { Decimal 'Price' -NotNull -Description 'The price of the item.' }

Demonstrates how to create a required decimal column with a description. Uses SQL Server's default precision/scale.