New-UniqueIdentifierColumn

Creates a column object representing an UniqueIdentifier datatype.

Syntax

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

Description

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

Add-Table 'WithUUID' {
    UniqueIdentifier 'ColumnName'
}

ALIASES

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The column's name.

true false
RowGuidCol SwitchParameter

Sets RowGuidCol

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 Locations { UniqueIdentifier 'LocationID' }

Demonstrates how to create a table with an optional uniqueidentifier column.

EXAMPLE 2

Add-Table Locations { UniqueIdentifier 'LocationID' -RowGuidCol }

Demonstrates how to create a table with an optional uniqueidentifier, which is used as the RowGuid identifier for SQL Server replication.

EXAMPLE 3

Add-Table Locations { UniqueIdentifier 'LocationID' -NotNull }

Demonstrates how to create a table with an required uniqueidentifier column.

EXAMPLE 4

Add-Table Locations { UniqueIdentifier 'LocationID' -Default 'newid()' }

Demonstrates how to create a table with an optional uniqueidentifier column with a default value.

EXAMPLE 5

Add-Table Locations { UniqueIdentifier 'LocationID' -Description 'The unique identifier for this location.' }

Demonstrates how to create a table with an optional uniqueidentifier column with a default value.