I need to set `CONTEXT_INFO` variable in SQL Server to user session unique identifier, GUID of user's session to be exact. 

But I cannot perform this operation in more or less short and clean one-liner. I'm obligatory to create new binary variable and only than assign it to the `CONTEXT_INFO`.

It looks like this:

```
DECLARE @sessionId binary(16) = CAST(CAST('A53BEEF9-4AFF-937A-857A-2C27B845B755' AS uniqueidentifier) AS binary(16)) 
SET CONTEXT_INFO @sessionId

```

It it possible to put everything into one line statement? 

Straightforward solution like following: 

```
SET CONTEXT_INFO CAST(CAST('A53BD5F9-4AFF-E211-857A-2C27D745B005' AS uniqueidentifier) AS binary(16)) 

```

This does not work, unfortunately. And I cannot get the reason of such behavior. 

**EDIT:**

`sessionId` will be generated on-fly, so hard coding constant binary value won't work...