Can not run cmdshell #command in SQL Server Express - sql-server-express

I can not run cmdshell #command commands in my SQL Server Express. Is it something to do with the SQL Server version? Should I have to have like SQL Server Standard edition to run this command?

Enable it, as described in the Microsoft article:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO

It was a permission issue which is fixed now! Thank you all for the help!

Related

SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security conf

We have enabled 'XPCmdShellEnabled' on the database serve and we used command shell script in one of the SP which executes on daily job.
(Our Command shell script basically create the directory, create the file and dump the tem table data to csv file).
Issue: From past few days the daily job filing with the below error, before that it was working fine and nobody changed any configurations on server.
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. For more information about enabling 'xp_cmdshell' search for 'xp_cmdshell' in SQL Server Books Online.
(We have enabled 'XPCmdShellEnabled' = true on 'Surface Area Configuration'.
I have tried again by executing below query, and tried SP.
sp_configure 'show advanced options', '1'
RECONFIGURE
sp_configure 'xp_cmdshell', '1'
RECONFIGURE
But no luck..
Please let me know if anybody aware/faced of this similar type of issue and found solution.
Thanks.

SQL SERVER - how can I rollback "use [MASTER]" query

I accidentally ran query Change authentication mode (T-SQL) in sql server:
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode', REG_DWORD, 1
GO
Now I can't work with SQL SERVER.
You can change it back using below code:
EXEC xp_instance_regwrite
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode',
REG_DWORD,
2; -- only difference is right here
You have changed authentication mode to windows only. So now you have to log in using windows account then you can change the authentication mode to mixed mode again. Or you can edit your registry to do so. Please check below link:
https://www.top-password.com/knowledge/sql-server-authentication-mode.html

SQL - Is running RECONFIGURE dangerous in production

I need to run the following on my production server:
EXEC sp_configure 'xp_cmdshell', 1;
GO
RECONFIGURE;
GO
My question is, Is there any danger running this command in a production environment. Would it drop any connection and would end users notice any down time?
There will be no downtime,
RECONFIGURE specifies that if the configuration setting does not require a server stop and restart, the currently running value should be updated
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/reconfigure-transact-sql
If you use 'with override' it can cause problems. i.e. it will allow you to change settings that you shouldn't change without a restart.
The usual proviso applies, you should test this in a test environment before using it in production.

SQL Server Agent cannot execute OPENROWSET query but I can - "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error

I'm trying to run an OPENROWSET query to an Excel sheet like so:
SELECT id, SourceName
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; HDR=YES; IMEX=1; Database=D:\MyFolder\Configuration.xlsx', 'SELECT * FROM [Sheet1$]')
When I execute this from SSMS it works. As part of a job step, it doesn't work with the error stated.
Things I've tried:
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO
Setting the permissions on the target spreadsheet & folders to 'Everyone' and 'Read/Write'
When I go to 'Server Objects' -> 'Linked Servers' -> 'Providers', Microsoft.ACE.OLEDB.12.0 is listed and it's in xp_enum_oledb_providers.
Access Database Engine x64 is installed.
This is SQL Server 2014.
Can anyone help? Why would the SQL Server Agent be unable to use the ACE provider when my user can?

How to Enable Create catalog Option in Integration Services Catalogs?

I want to create a SSIS catalog and the way to create a catalog is to right click on "Integration Services Catalogs" node and select "Create Catalog" option.
But "Create Catalog" option is disable , how to enable this option ?
To check if SSIS installed, open Sql Server Configuration Manager, in the SQL Server Services, is something like 'SQL Server Integration Services ' running?
I had this problem and I found the above solution in belew link:
Can't create a SSISDB catalog due to missing SSISDBBackup.bak file, even though SSIS is installed
Sp_configure 'show advanced options',1;
Go
Reconfigure;
Go
Sp_configure 'clr enabled',1;
Go
Reconfigure
Go
Run the above command from master database