回答

2

它工作在我的環境:

enter image description here

我想我也有類似的問題,因爲我沒有使用最新的SQL Server Management Studio。你可以找到最新版本here

生成的代碼看起來是這樣的 - 我認爲你可以改變它,嘗試,如果你不能保存爲PS腳本:

# Generated by SQL Server Management Studio at 9:15 AM on 2017-10-09 

Import-Module SqlServer 
# Set up connection and database SMO objects 

$sqlConnectionString = "Data Source=SQLInstanceName\INST1;Initial Catalog=databaseName;Integrated Security=True;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;Packet Size=4096;Application Name=`"Microsoft SQL Server Management Studio`"" 
$smoDatabase = Get-SqlDatabase -ConnectionString $sqlConnectionString 

# If your encryption changes involve keys in Azure Key Vault, uncomment one of the lines below in order to authenticate: 
# * Prompt for a username and password: 
#Add-SqlAzureAuthenticationContext -Interactive 

# * Enter a Client ID, Secret, and Tenant ID: 
#Add-SqlAzureAuthenticationContext -ClientID '<Client ID>' -Secret '<Secret>' -Tenant '<Tenant ID>' 

# Change encryption schema 

$encryptionChanges = @() 

# Add changes for table [dbo].[TablenameX] 
$encryptionChanges += New-SqlColumnEncryptionSettings -ColumnName dbo.TablenameX.columNameX -EncryptionType Deterministic -EncryptionKey "CEK_Auto1" 

Set-SqlColumnEncryption -ColumnEncryptionSettings $encryptionChanges -InputObject $smoDatabase 

的SQL版本是:

Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0 (X64) Oct 28 2016 18:17:30 Copyright (c) Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600:) (Hypervisor)

而且SSMS版本是Microsoft SQL Server Management Studio 14.0.17177.0 - 或來自我提供的鏈接的v17.2。

+0

謝謝你,如果我可以在SSMS 2016下進行測試,我會保持你的發佈,因爲這個實例實際上是MS SQL 13(2016)。 –

+0

請注意,現在SSMS的安裝不是SQL Server安裝的一部分。您可以從鏈接免費下載文件並安裝它 - 有兩個版本的SSMS也可以。 – gotqn

+0

老兄,我可以問你的實例版本(SQL服務器)和你的SSMS版本嗎?即時通訊使用SSMS 2016,但仍然獲得相同的行爲@gotqn –

相關問題