New-HierarchyIDColumn

Creates a column object representing an HierarchyID datatype.

Syntax

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

Description

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

Add-Table 'FamilyTree' {
    HierarchyID 'Father'
}

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 'FamilyTree' { HierarchyID 'Father' }

Demonstrates how to create an optional hierarchyid column called Father.

EXAMPLE 2

Add-Table 'FamilyTree' { HierarchyID 'Father' -NotNull }

Demonstrates how to create a required hierarchyid column called Father.

EXAMPLE 3

Add-Table 'FamilyTree' { HierarchyID 'Father' -Sparse }

Demonstrates how to create a sparse, optional hierarchyid column called Father.

EXAMPLE 4

Add-Table 'FamilyTree' { HierarchyID 'Father' -NotNull -Description "The hierarchy ID of this person's father." }

Demonstrates how to create a required hierarchyid column with a description.