Search code examples
sql-serverazurerow-level-security

'SESSION_CONTEXT' is not a recognized built-in function name - SQL Server


I have an Azure SQL Database. I am trying to execute the following query on SQL Server Management Studio 2016:

ALTER TABLE Contacts ADD UserId nvarchar(128)
    DEFAULT CAST(SESSION_CONTEXT(N'UserId') AS nvarchar(128))

I get the following error:

Msg 195, Level 15, State 10, Line 22
'SESSION_CONTEXT' is not a recognized built-in function name.

I am following this row level security tutorial: https://github.com/Azure/azure-content/blob/master/articles/app-service-web/web-sites-dotnet-entity-framework-row-level-security.md


Solution

  • You have to upgrade your SQL Server on Azure portal to V12. I think this could work.