- Remove From My Forums
-
Question
-
With sql server 2008 r2 express I tried to import data from an Excel spreadsheet into a database and I got this error message:
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component
‘Ad Hoc Distributed Queries’ because this component is turned off as part of
the security configuration for this server. A system administrator can enable the use of
‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling
‘Ad Hoc Distributed Queries’, see «Surface Area Configuration» in SQL Server Books Online.
For the import I used INSERT INTO tableName SELECT Portfolio FROM OPENROWSET
The database I tried to import into came from another server. The import works in that other server.
Does anyone know how I can do the import?
carl.g.b
Answers
-
Carl,
You’ll need to enable the configuration noted in the error, assuming you have sysadmin.
sp_configure 'show advanced', 1 reconfigure GO sp_configure 'Ad Hoc Distributed Queries', 1 reconfigure GO sp_configure 'show advanced',0 reconfigure GO
-Sean
Sean Gallardy | Blog |
Twitter-
Marked as answer by
Tuesday, November 27, 2012 12:52 AM
-
Marked as answer by
Let’s see how to fix the error “15281: SQL server blocked access to procedure” in this article. Bobcares, as a part of our Server Management Services offers solutions to every query that comes our way.
Error 15281: SQL Server Blocked Access To Procedure
Once we install the SQL server and try to execute a query statement, we may see the following error:
SQL Server blocked access to procedure ‘procedure’ of component ‘component’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘component’ by using sp_configure. For more information about enabling ‘component’, see “Surface Area Configuration” in SQL Server Books Online.
The error details are as follows:
Message Number: 15281
Severity: 16
How to fix error 15281: SQL Server Blocked Access To Procedure?
Due to security configuration, certain SQL Server features or procedures are blocked by default. As a result, some procedures are no longer available.
In order to use such procedures, a database administrator must log in to a SQL Server instance with System Administrator (SA) privileges and execute the TSQL statement listed below to enable that SQL Server functionality. In this section, we will see how we can fix it using an example, Database Mail XPs.
Error:

Fix:
USE MASTER
GO
SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
/* Enable Database Mail XPs Advanced Options in SQL Server */
SP_CONFIGURE 'Database Mail XPs', 1
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO
[Need help with another query? We’re available 24/7.]
Conclusion
In this article, we provide a simple solution from our Support team to fix the above error.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
Проблемы
Рассмотрим следующий сценарий.
-
У вас есть экземпляр Microsoft SQL Server 2008 R2, на котором размещается контрольная точка пользователя (UCP).
-
Вы установили накопительный пакет обновления 1 (SP1) для SQL Server 2008 R2 на экземпляре.
В этом случае установка завершается успешно. Однако не удается запустить службу SQL Server. Кроме того, в файле Errorlog сервера SQL Server регистрируются следующие сообщения об ошибках:
<Date>
<Time> spid7s выполнение [sysutility_mdw]. Sysutility_ucp_core. sp_initialize_mdw_internal<Дата><время> spid7s SQL Server заблокировал доступ к процедуре «sys. xp_qv» агента XPS, так как этот компонент отключен как часть конфигурации безопасности для этого сервера. Системный администратор может включить использование «агента XPs» с помощью sp_configure. Дополнительные сведения о включении агента XPs можно найти в разделе Настройка настройки контактной зоны в электронной документации по SQL Server.<дата><время> spid7s ошибка: 15281, уровень серьезности: 16, состояние: 1.<Date><Time> spid7s SQL Server блокировал доступ к процедуре «sys.xp_qv» для компонента агента XPS, так как этот компонент отключен как часть конфигурации безопасности для этого сервера. Системный администратор может включить использование «агента XPs» с помощью sp_configure. Дополнительные сведения о включении агента XPs можно найти в разделе Настройка настройки контактной зоны в электронной документации по SQL Server.<дата><время> spid7s ошибка: 912, уровень серьезности: 21, состояние: 2.<дата><время> обновление уровня сценария spid7s для базы данных «Master» завершилось сбоем, так как при обновлении «sqlagent100_msdb_upgrade. SQL» произошла ошибка 15281, состояние 1, степень серьезности 16. Это серьезная ошибка, которая может повлиять на нормальную работу, и база данных будет переведена в автономный режим. Если во время обновления базы данных «Master» произошла ошибка, это не помешает запуску всего экземпляра SQL Server. Проверьте предыдущие записи ErrorLog на наличие ошибок, выполните необходимые корректирующие действия и перезапустите базу данных, чтобы выполнить шаги по обновлению сценария до завершения.<дата><время> spid7s ошибка: 3417, уровень серьезности: 21, состояние: 3.<Date><Time> spid7s не может восстановить базу данных master. Не удается запустить SQL Server. Восстановите образец из полной резервной копии, исправьте ее или перестройте. Дополнительные сведения о том, как перестроить базу данных master, можно найти в книге SQL Server Books Online.<Date><Time> spid7s трассировка SQL была остановлена из-за завершения работы сервера. Trace ID = «1». Это информационное сообщение; никаких действий пользователя не требуется.
Эта проблема также может возникать при обновлении экземпляра версии-кандидата SQL Server 2008 R2 (RC), на котором размещается точка управления служебной программой, на выпускную версию SQL Server 2008 R2.
Причина
Эта проблема возникает из-за того, что при использовании SQL Server 2008 R2 при выполнении сценария обновления для базы данных msdb функция агента XPs не включена. Этот сценарий выполняется при запуске службы SQL Server. Сценарий запускает сохраненную процедуру, связанную с точки управления служебной программой. Кроме того, хранимая процедура требует, чтобы был включен параметр агента XPs.
Решение
Сведения о накопительном пакете обновления
Исправление для этой проблемы впервые выпущено в накопительном обновлении 2. Для получения дополнительных сведений о том, как получить этот накопительный пакет обновления для SQL Server 2008 R2, щелкните следующий номер статьи базы знаний Майкрософт:
2072493 Накопительный пакет обновления 2 (SP2) для SQL Server 2008 R2Примечание. Поскольку сборки являются кумулятивными, каждый новый выпуск исправлений содержит все исправления и все исправления безопасности, которые были включены в предыдущий выпуск исправлений для SQL Server 2008 R2. Рекомендуется установить последнюю версию исправления, которая включает это исправление. Дополнительные сведения см. в следующей статье базы знаний Майкрософт:
981356 Сборки SQL Server 2008 R2, выпущенные после выпуска SQL Server 2008 R2
Обходное решение
Примечание. Если вы еще не установили накопительный пакет обновления 1 (SP1), вы должны воспользоваться разделом «решение», чтобы установить накопительный пакет обновления 2. Эта проблема не существует в накопительном пакете обновления 2 и более поздних версиях для SQL Server 2008 R2. Если проблема возникает после установки накопительного пакета обновления 1, выполните указанные ниже действия, чтобы устранить эту проблему.
-
Включите флаг трассировки 902 в экземпляре SQL Server 2008 R2. Для этого выполните следующие действия:
-
Откройте диспетчер конфигурации SQL Server.
-
В диспетчере конфигурации SQL Server выберите пункт службы SQLServer.
-
Дважды щелкните службу SQL Server .
-
В диалоговом окне Свойства SQL Server откройте вкладку Дополнительно .
-
На вкладке Дополнительно найдите пункт Параметры запуска .
-
Добавьте ;-T902 в конец существующего строкового значения и нажмите кнопку ОК.
-
-
Щелкните правой кнопкой мыши службу SQL Server и выберите команду Пуск.
-
Если запущена служба агента SQL Server, щелкните правой кнопкой мыши службу агента SQL Server и выберите команду остановить.
-
Откройте центр SQL Server Management Studio и подключитесь к экземпляру SQL Server 2008 R2.
-
Выполните следующие инструкции:
EXEC sp_configure «Show Advanced», 1; Перенастройка EXEC sp_configure «разрешить обновления», 0; Перенастройка EXEC sp_configure «Agent XPs», 1; Перенастройка Щелкните
-
В диспетчере конфигурации SQL Server щелкните правой кнопкой мыши службу SQL Server и выберите команду остановить.
-
Удалите флаг трассировки 902 в экземпляре SQL Server 2008 R2. Для этого удалите ;-T902 из строкового значения, которое вы обновили в действии 1F.
-
Щелкните правой кнопкой мыши службу SQL Server и выберите команду Пуск.
-
Щелкните правой кнопкой мыши службу агента SQL Server и выберите команду запустить.
-
В SQL Server Management Studio повторно подключитесь к экземпляру SQL Server 2008 R2.
-
В обозревателе объектов разверните узел Управление, щелкните правой кнопкой мыши коллекцию данныхи выберите пункт включить сбор данных.Примечание. Если коллекция данных уже включена, элемент «включить сбор данных» недоступен.
Примечание. При подключении к экземпляру SQL Server 2008 R2 в SQL Server Management Studio может появиться следующее сообщение об ошибке:
Ошибка: не удалось 18401Login пользователя «<имя входа>«. Причина: сервер находится в режиме обновления сценария. В настоящее время подключиться может только администратор.
Это сообщение об ошибке указывает на то, что SQL Server 2008 R2 завершает установку накопительного пакета обновления 1. Если вы получили это сообщение об ошибке, подождите несколько минут, а затем снова подключитесь к экземпляру SQL Server 2008 R2.
Статус
Корпорация Майкрософт подтверждает наличие этой проблемы в своих продуктах, которые перечислены в разделе «Применяется к».
Ссылки
Чтобы получить сведения о модели добавочного обслуживания для SQL Server, щелкните следующий номер статьи базы знаний Майкрософт:
935897 Модель обслуживания изменений, используемая рабочей группой SQL Server, предоставляет модель ISM для распространения исправлений обнаруженных проблем Чтобы получить дополнительные сведения о схеме присвоения имен обновлениям SQL Server, щелкните следующий номер статьи базы знаний Майкрософт:
822499 Принцип именования пакетов обновления программного обеспечения Microsoft SQL Server Чтобы получить дополнительные сведения о терминологии обновления программного обеспечения, щелкните следующий номер статьи базы знаний Майкрософт:
824684 Стандартные термины, используемые при описании обновлений программных продуктов Майкрософт
Нужна дополнительная помощь?
January 19, 2014 by Muhammad Imran
Today, I installed a SQL Server instance in one of my labs, and tried to run a query using OPENROWSET and got an error. Given below are the details of the error.
Message Number: 15281
Severity : 16
Error Message: SQL Server blocked access to %S_MSG ‘%ls’ of component ‘%.*ls’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘%.*ls’ by using sp_configure. For more information about enabling ‘%.*ls’, see “Surface Area Configuration” in SQL Server Books Online.
Error Generation:
Given below is the script that I tried to execute but it resulted with the following error:
USE AdventureWorks2012
GO
SELECT *
FROM OPENROWSET('SQLNCLI', 'Server=(local);uid=test;pwd=test',
'EXEC AdventureWorks2012.[dbo].[uspGetManagerEmployees] 16');
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT ‘OpenRowset/OpenDatasource’ of component ‘Ad Hoc Distributed Queries’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ad Hoc Distributed Queries’ by using sp_configure. For more information about enabling ‘Ad Hoc Distributed Queries’, search for ‘Ad Hoc Distributed Queries’ in SQL Server Books Online.
Ooopps…… I am unable to execute the OPENROWSET query.
Resolution:
Basically, ‘Ad hoc Distributed Queries’ are disabled by default in SQL Server due to security configuration and you cannot use either OPENROWSET or OPENDATASOURCE and if you cannot execute these two rowset functions, then you cannot access any remote data sources. So how to fix this issue?
Given below is the script to enable ‘Ad hoc Distributed Queries’.
USE master GO sp_configure 'show advanced options', 1; RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; RECONFIGURE; GO --OUTPUT
Configuration option ‘show advanced options’ changed from 0 to 1. Run the RECONFIGURE statement to install.
Configuration option ‘Ad hoc Distributed Queries’ changed from 0 to 1. Run the RECONFIGURE statement to install.
As you can see above, the ‘Ad hoc Distributed Queries’ setting changed from 0 to 1. Now you can easily execute any ‘Ad hoc Query’
Note : By default, this option is set to 0 and you need to change it to 1 to activate this feature.
Posted in Errors, SQL SERVER | Tagged Msg 15281 Level 16 State 1, raresql, SQL, SQL Server, SQL Server 2012 | Leave a Comment
Home
> SQL Errors > SQL Error – Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1 SQL Server blocked access because this component is turned off
I was trying to execute a Windows Shell command from SSMS by using xp_cmdshell Extended Stored Procedure and encountered an error highlighted below in RED color:
EXEC xp_cmdshell 'DIR *.exe'
Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure.
Even if you are a sysadmin and as by default this option is turned off after a new SQL Server installation, you need to manually turn on this option, let’s see how:
-- To change the advanced options: EXEC sp_configure 'show advanced options', 1 GO -- To update the current value for advanced options: RECONFIGURE GO -- To enable the xp_cmdshell option: EXEC sp_configure 'xp_cmdshell', 1 GO -- To update the new configured value for xp_cmdshell option: RECONFIGURE GO
–> If you want to suppress the messages returned by the xp_cmdshell extended Stored Procedure use the optional parameter no_output.
exec xp_cmdshell 'DIR *.exe', no_output
Please Note: If xp_cmdshell is executed within a BATCH and returns an error, the complete batch will fail. In earlier versions of SQL Server the batch used to continue executing.
If the user is not member of sysadmin role and want to use this extended SP then a Proxy account credential need to be created by using sp_xp_cmdshell_proxy_account. Check this KB article for the same: link.
I’m upgrading our reporting server from 2008 R2 32-bit to 2014 32-bit.
We have linked servers that are excel files. These are .xls files (although the problem persists when they are updated to .xlsm). The connects work fine (select & insert into); however, when we run a stored procedure to create a new tab in the excel file.
USE [SupplementaryReports]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[spExecute_ADODB_SQL]
@DDL VARCHAR(8000),
@DataSource VARCHAR(500),
@Worksheet VARCHAR(200)=NULL,
@ConnectionString VARCHAR(255) = 'Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=%DataSource;
Extended Properties=Excel 12.0'
AS
DECLARE
@objExcel INT,
@hr INT,
@command VARCHAR(255),
@strErrorMessage VARCHAR(255),
@objErrorObject INT,
@objConnection INT,
@bucket INT
SELECT @ConnectionString =REPLACE (@ConnectionString, '%DataSource', @DataSource)
IF @Worksheet IS NOT NULL
SELECT @DDL=REPLACE(@DDL,'%worksheet',@Worksheet)
SELECT @strErrorMessage='Making ADODB connection ',
@objErrorObject=NULL
EXEC @hr=sp_OACreate 'ADODB.Connection', @objconnection OUT
IF @hr=0
SELECT @strErrorMessage='Assigning ConnectionString property "'
+ @ConnectionString + '"',
@objErrorObject=@objconnection
IF @hr=0 EXEC @hr=sp_OASetProperty @objconnection, 'ConnectionString', @ConnectionString
IF @hr=0 SELECT @strErrorMessage ='Opening Connection to XLS, for file Create or Append'
IF @hr=0 EXEC @hr=sp_OAMethod @objconnection, 'Open'
IF @hr=0 SELECT @strErrorMessage ='Executing DDL "'+@DDL+'"'
IF @hr=0 EXEC @hr=sp_OAMethod @objconnection, 'Execute',
@Bucket out , @DDL
IF @hr<>0
BEGIN
DECLARE
@Source VARCHAR(255),
@Description VARCHAR(255),
@Helpfile VARCHAR(255),
@HelpID INT
EXECUTE sp_OAGetErrorInfo @objErrorObject, @source output,
@Description output,@Helpfile output,@HelpID output
SELECT @strErrorMessage='Error whilst '
+COALESCE(@strErrorMessage,'doing something')+', '
+COALESCE(@Description,'')
RAISERROR (@strErrorMessage,16,1)
END
EXEC @hr=sp_OADestroy @objconnection
GO
I get the following error
Msg 15281, Level 16, State 1, Procedure sp_OACreate, Line 116
SQL Server blocked access to procedure ‘sys.sp_OACreate’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, search for ‘Ole Automation Procedures’ in SQL Server Books Online.
Msg 15281, Level 16, State 1, Procedure sp_OADestroy, Line 116
SQL Server blocked access to procedure ‘sys.sp_OADestroy’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, search for ‘Ole Automation Procedures’ in SQL Server Books Online.
This error often means that ad hoc distribtued queries are not enough. But they are (both ‘show advanced options’ and ‘ad hoc distributed queries’ are set to 1). We also have the provider Microsoft.ACE.OLEDB.12.0 with allow in process and dynamic paramteres enabled.
The excel files work perfectly with 2008 R2. The code itself hasn’t been changed. All that’s changed is upgrading to 2014. Does anyone have any suggestions? You know… besides not using SQL to connect to excel files since we don’t have the resources to change that.
Much obliged!
Hello,
I want to create jobs but I can’t as the SQL Server Agent is disabled, I upgraded from Express to Standard a while ago. Pictures below:
Managment Studio:
https://i.imgur.com/thxGmmE.png
Configuration Manager:
https://i.imgur.com/Q1hqZrv.png
I try and click properties, I get this error:
Cannot show requested dialog.
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
SQL Server blocked access to procedure ‘dbo.sp_get_sqlagent_properties’ of component ‘Agent XPs’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Agent XPs’ by using sp_configure. For more information about enabling ‘Agent XPs’, search for ‘Agent XPs’ in SQL Server Books Online. (Microsoft SQL Server, Error: 15281)
How do I enable this?
Thank you!
check
Best Answer

Alec6638

This person is a verified professional.
Verify your account
to enable IT peers to see that you are a professional.
thai pepper
Microsoft SQL Server Expert
-
check
131
Best Answers -
thumb_up
314
Helpful Votes
You upgrade an existing SQL instance named SQLEXPRESS from SQL Express to SQL Standard and kept the same instance name SQLEXPRESS ?
That’s going to be confusing to many (including us!).
Anyways, let’s try to enable SQL Agent service. Rather than doing this from the Admin Tools -> Services window, it is better to do it from SQL Server Configuration Manager. Look for ‘SQL Server Agent (SQLEXPRESS)’ .

You should be able to figure out how to enter your account and password and to hopefully get the Agent service started. Use a domain account if you anticipate that your agent will need access to network resources outside of your SQL server; use a built-in local service account if no network resources needed.
1 found this helpful
thumb_up
thumb_down
View Best Answer in replies below
Read these next…

WINDOWS 10 «glitch» — file explorer
Windows
Hi.I have been experiencing a black line (glitch) on my file explorer which comes for milliseconds then it goes away. See screen grab. Is there anyone who has experienced such and how were they able to solve it?Thank you.

Are you updating workstations to Windows 11?
Windows
Has anyone started updating workstations on a AD domain to Windows 11? what type of issues are you facing?What is the user reaction been?Thanks!

Snap! — Psyche Probe, DIY Gene Editing, RaiBo, AI handwriting, Metric Pirates
Spiceworks Originals
Your daily dose of tech news, in brief.
Welcome to the Snap!
Flashback: January 27, 1880: Thomas Edison receives patent for the Electric Lamp. (Read more HERE.)
Bonus Flashback: January 27, 1967: Apollo 1 Tragedy (Read more HERE.)
You …

NEC Inmail Email doesn’t Change
Collaboration
Hey Everyone,Recently a client of mine wanted to change the email to their QA extension to her email as to help keep voicemails consolidated instead of spread out among different emails. Normally this wouldn’t be a huge deal. Logged in to to Webpro, hoppe…

I inherited some really cool equipment. I just have no clue how to use it!
Hardware
So I’ve got some switches, and some servers. The switches seem pretty straight forward, plug in packet go zoom, but I have no clue how these servers work. They’re headless rack servers. I know there must be a way to get some kind of UI going with a monito…
I have two boxes runing SQL 2005 that i’m not able to get Database Mail working on. I’ve gone thru the Wizard to set up my profiles and system parameters, I’ve created an operator in SQL Agent, I’ve enabled Database mail on SQL Server 2005 Surface
Area configuration as well as SQL Mail. but when I right click on Database mail and Try to send a test Message i get the error below.
TITLE: Microsoft SQL Server Management Studio
——————————
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
ADDITIONAL INFORMATION:
SQL Server blocked access to procedure ‘dbo.sp_send_dbmail’ of component ‘Database Mail XPs’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Database Mail XPs’ by using
sp_configure. For more information about enabling ‘Database Mail XPs’, see «Surface Area Configuration» in SQL Server Books Online. (Microsoft SQL Server, Error: 15281)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4035&EvtSrc=MSSQLServer&EvtID=15281&LinkId=20476
——————————
BUTTONS:
OK
——————————
Please advise.
Thanks
I have two boxes runing SQL 2005 that i’m not able to get Database Mail working on. I’ve gone thru the Wizard to set up my profiles and system parameters, I’ve created an operator in SQL Agent, I’ve enabled Database mail on SQL Server 2005 Surface
Area configuration as well as SQL Mail. but when I right click on Database mail and Try to send a test Message i get the error below.
TITLE: Microsoft SQL Server Management Studio
——————————
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
ADDITIONAL INFORMATION:
SQL Server blocked access to procedure ‘dbo.sp_send_dbmail’ of component ‘Database Mail XPs’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Database Mail XPs’ by using
sp_configure. For more information about enabling ‘Database Mail XPs’, see «Surface Area Configuration» in SQL Server Books Online. (Microsoft SQL Server, Error: 15281)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4035&EvtSrc=MSSQLServer&EvtID=15281&LinkId=20476
——————————
BUTTONS:
OK
——————————
Please advise.
Thanks