Operand type clash when use Always Encrypted

Andrei Tselichtchev 0 Reputation points
2025-02-05T16:46:21.75+00:00

When I connect SSMS to a SQL Server 2022 database with Always Encrypted enabled, I get the following error: "Msg 206, Level 16, State 2, Line 3 - Operand type clash: datetime is incompatible with uniqueidentifier."

This occurs with the code below:

DECLARE @Date AS DateTime = GETDATE(); 
DECLARE @Id AS uniqueidentifier; 

However, if I change the order of the declarations, the error disappears.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,422 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.