Problem with CREATE SECURITY POLICY in SQL Server 2014 SP3 - sql-server

I'm trying to create a security policy with this query:
CREATE SECURITY POLICY Security.DegreeFilter
ADD FILTER PREDICATE Security.fn_securitypredicate(Degree) ON Students
WITH (STATE = ON);
But I get this error:
Msg 343, Level 15, State 1, Line 1
Unknown object type 'SECURITY' used in a CREATE, DROP, or ALTER statement.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'FILTER'.
I'm using SQL Server 2014 SP3.
SELECT ##version returns Microsoft SQL Server 2014 (SP3).
compatibility_level for my database is 120.

According to the Documentation
CREATE SECURITY POLICY only applies to SQL Server 2016 (13.x) and later

Related

Need help to enable Change Data Capture (CDC) on SQL Server

I'm looking to enable change data capture on a SQL Server Database.
Version: Microsoft SQL Azure (RTM) - 12.0.2000.8 Apr 9 2020 16:39:55 Copyright (C) 2019 Microsoft Corporation
Used below command to check if the CDC is enabled on the db and it returned '0'
SELECT is_cdc_enabled
FROM sys.databases
WHERE name = 'XXXX';
Tried to enable the CDC at the database level by issuing below command ..
EXEC sys.sp_cdc_enable_db
It returned below error message
Msg 22830, Level 16, State 1, Procedure sys.sp_cdc_enable_db_internal, Line 198 [Batch Start Line 4]
Could not update the metadata that indicates database XXXX is enabled for Change Data Capture. The failure occurred when executing the command 'SetCDCTracked(Value = 1)'. The error returned was 22845: 'Cannot enable change data capture in this edition of SQL Server.'. Use the action and error to determine the cause of the failure and resubmit the request.
Now my question is- do I need admin privileges to enabled CDC or is this feature not available with Azure SQL server version? Thanks for reading and your help is appreciated.
Please reference this document: Enable and Disable Change Data Capture (SQL Server)
The feature only support Azure SQL managed instance. For Azure SQL database, wen can not Enable and Disable Change Data Capture.
Hope this helps.
CDC is now Available for Azure SQL Databases

Error when executing SQL scripts with SQL Server authentication

I have some issue when executing scripts in SQL.
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 8.0;Database=D:\Application\myExcel.xls;',
'SELECT * FROM [Sheet1$]')
When I login to SQL Server with Windows authentication, the script above runs successfully.
But when I login to SQL Server with SQL Server authentication (not sa account), the script throw this error:
Msg 7399, Level 16, State 1, Line 8
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Line 8
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
Could anyone please tell me why and how to fix it?
I'm using SQL Server 2012 (x64), Windows Server 2012 R2.
Thank you very much.

'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
You have to upgrade your SQL Server on Azure portal to V12. I think this could work.

Transactional replication errors

I'm trying to set up transactional replication in SQL Server 2012 using AdventureWorks 2012. And right at the end of the publications setup i get the following error:
SQL Server could not start the Snapshot Agent.
Additional Information:
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
SQL ServerAgent is not currently running so it cannot be modified of this action.
Changed database context to 'AdventureWorks2012'.(Microsoft SQL Server,Error 22022)
I'm guessing this error isn't allowing me to execute the following code:
USE ADRepl;
SELECT * FROM Person.BusinessEntity
As every time I do execute this I get the following error:
Msg 208, Level 16, State 1, Line 2
Invalid object name 'Person.BusinessEntity'.
Make your sql agent property as automatic.
Set the SQL server agent service Automatically.
Press windows key+R
type services.msc
right Click on sql server agent
properties >> startup >> select automatically.

how to restore sql server database without store procedures?

I made a full database backup. I wanted to restore this database in another distant machine.
However, database restoration failed with:
Msg 7202, Level 11, State 2, Server MySERVER\SQLEXPRESS, Procedure _SBOF_FOO1, Line 17
Could not find server 'svr1' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.
Aparently, there is a store procedure that has a reference to a server 'svr1' which cannot find. How to work around this error?

Resources