You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Rivet/Functions/Operations/Add-Description.ps1
+44-16Lines changed: 44 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ function Add-Description
3
3
{
4
4
<#
5
5
.SYNOPSIS
6
-
Adds the `MS_Description` extended property to a table or column.
6
+
Adds the `MS_Description` extended property to schemas, tables, columns, views, and view columns.
7
7
8
8
.DESCRIPTION
9
9
The `sys.sp_addextendedproperty` stored procedure is used to set a table/column's description (i.e. the `MS_Description` extended property), but the syntax is weird. This function hides that weirdness from you. You're welcome.
PowerShell v2.0 doesn't parse the parameters correctly when setting a table name, so you have to explicitly tell it what to do. Upgrade to PowerShell 3!
25
+
26
+
.EXAMPLE
27
+
Add-Description -Description 'This is an extended property on a schema' -SchemaName 'test'
28
+
29
+
Adds a description (i.e. the `MS_Description` extended property) on the `test` schema.
30
+
31
+
.EXAMPLE
32
+
Add-Description -Description 'This is an extended property on a view' -SchemaName 'test' -ViewName 'testVw'
33
+
34
+
Adds a description (i.e. the `MS_Description` extended property) on the `testVw` view.
35
+
36
+
.EXAMPLE
37
+
Add-Description -Description 'This is an extended property on a view column' -SchemaName 'test' -ViewName 'testVw' -ColumnName 'ID'
38
+
39
+
Adds a description (i.e. the `MS_Description` extended property) on the `ID` column in the 'testVw' view.
25
40
#>
26
41
[CmdletBinding()]
27
42
param(
28
-
[Parameter(Mandatory=$true,Position=0)]
29
-
[string]
30
43
# The value for the MS_Description extended property.
31
-
$Description,
44
+
[Parameter(Mandatory,Position=0)]
45
+
[String] $Description,
32
46
33
-
[Alias('Schema')]
34
-
[string]
35
47
# The schema. Defaults to `dbo`.
36
-
$SchemaName='dbo',
48
+
[Parameter(ParameterSetName='ForSchema')]
49
+
[Parameter(ParameterSetName='ForTable')]
50
+
[Parameter(ParameterSetName='ForView')]
51
+
[Parameter(ParameterSetName='ForColumn')]
52
+
[Alias('Schema')]
53
+
[String] $SchemaName='dbo',
37
54
38
-
[Parameter(Mandatory=$true)]
39
-
[Alias('Table')]
40
-
[string]
41
55
# The name of the table where the extended property is getting set.
ThenMigration -HasContent 'Add-View -SchemaName ''crackle'' -Name ''CrackleView'' -Description ''This is the MS Description for the view CrackleView'''
1284
+
}
1285
+
1286
+
Describe 'Export-Migration.when view column has an extended property' {
Add-ExtendedProperty -Name 'MS_Description' -SchemaName 'pop' -ViewName 'PopView' -ColumnName 'ID' -Value 'This is the MS Description for column ID in the view PopView'
ThenMigration -HasContent 'Add-ExtendedProperty -SchemaName ''pop'' -ViewName ''PopView'' -ColumnName ''ID'' -Value -Description ''This is the MS Description for column ID in the view PopView'''
0 commit comments