New-SmallDateTimeColumn

Creates a column object representing an SmallDateTime datatype.

Syntax

New-SmallDateTimeColumn [-Name] <String> [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-SmallDateTimeColumn [-Name] <String> -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]

Description

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

Add-Table 'Orders' {
    SmallDateTime 'OrderedAt'
}

ALIASES

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The column's name.

true 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 'Orders' { New-SmallDateTimeColumn 'OrderedAt' -NotNull }

Demonstrates how to create a required smalldatetime colum when adding a new table.

EXAMPLE 2

Add-Table 'Orders' { SmallDateTime 'OrderedAt' -Sparse }

Demonstrate show to create a nullable, sparse smalldatetime column when adding a new table.

EXAMPLE 3

Add-Table 'Orders' { SmallDateTime 'OrderedAt' -NotNull -Default 'getutcdate()' }

Demonstrates how to create a smalldatetime column with a default value. You only use UTC dates, right?

EXAMPLE 4

Add-Table 'Orders' { SmallDateTime 'OrderedAt' -NotNull -Description 'The time the record was created.' }

Demonstrates how to create a smalldatetime column a description.