New-SqlVariantColumn

Creates a column object representing an SqlVariant datatype.

Syntax

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

Description

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

Add-Table 'WithSqlVariant' {
    SqlVariant 'ColumnName'
}

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 'WithSqlVar' { SqlVariant 'WhoKnows' }

Demonstrates how to create an optional sql_variant column called WhoKnows.

EXAMPLE 2

Add-Table 'WithSqlVar' { SqlVariant 'WhoKnows' -NotNull }

Demonstrates how to create a required sql_variant column called WhoKnows.

EXAMPLE 3

Add-Table 'WithSqlVar' { SqlVariant 'WhoKnows' -Sparse }

Demonstrates how to create a sparse, optional sql_variant column called WhoKnows.

EXAMPLE 4

Add-Table 'WithSqlVar' { SqlVariant 'WhoKnows' -NotNull -Default '1' }

Demonstrates how to create a required sql_variant column called WhoKnows with a default value of 1.

EXAMPLE 5

Add-Table 'WithSqlVar' { SqlVariant 'WhoKnows' -NotNull -Description 'The contents of this column are left as an exercise for the reader.' }

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