title: GETDATE() Function error on TSQL with Always Encrypted Column
body: <p>I am working with SQL Server hosted on Azure. I have a table named "ERROR" with a column named "DATETIME" with Always Encrypted feature enabled.</p>
  
  <pre><code>CREATE TABLE [dbo].[ERROR]
  (
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [DATETIME] [datetime] ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [CEK_Auto1], ENCRYPTION_TYPE = Deterministic, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256') NOT NULL,
      [CODE] [varchar](10) NOT NULL,
      [MESSAGE] [varchar](500) NULL,
  
      CONSTRAINT [PK_ERROR] 
          PRIMARY KEY CLUSTERED ([ID] ASC)
  ) 
  </code></pre>
  
  <p>I'm running a stored procedure to add a row in another table, but if an error is caught it add the error to this table with the following statement:</p>
  
  <pre><code>INSERT INTO [dbo].[ERROR] ([DATETIME], [CODE], [MESSAGE])
  VALUES (GETDATE(), @@ERROR, ERROR_MESSAGE())
  </code></pre>
  
  <p>My issue is when I try to enter <code>GETDATE()</code> value into the encrypted column, I get this error</p>
  
  <blockquote>
    <p>Operand type clash: datetime is incompatible with datetime encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'Aeropuerto')</p>
  </blockquote>
  
  <p>Following some recommendations on the web I enabled PARAMETERIZATION FOR ALWAYS ENCRYPTED on SSMS and declared it first like this <code>DECLARE @RAISEDTIME DATETIME = '20181130'</code>. after this no error was raised and it is inserted successfully, but when assing GETDATE() as value [<code>DECLARE @RAISEDTIME DATETIME = GETDATE()</code>] I get this error:</p>
  
  <blockquote>
    <p>Encryption scheme mismatch for columns/variables '@RAISEDTIME'. The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '3' expects it to be (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'Aeropuerto') (or weaker).</p>
  </blockquote>
  
  <p>I have tried to format <code>GETDATE()</code> value with ISO8601 but the same error below is raised.</p>
  
  <p>Can you recommend me a way to insert the actual datetime value with this stored procedure? </p>