xp_cmdshell on SQL Server Linux Public Preview - sql-server

I am using the Public Preview of SQL Server 2016 on Linux.
I am trying to run xp_cmdshell and get the following error.
I suspect it has to do with permissions but have no idea how to fix this.
I have spent many hours searching for some answers but there seems to be little support for SQL Server on Linux.
I am running this using an administrator account.
SQL Server is installed on Ubuntu 16.4 (as recommended).
I connect to it with Microsoft SQL Management Studio running on Windows 10.
SQL code:
EXEC xp_cmdshell #SQLtext, no_output
Error message:
Msg 15121, Level 16, State 21, Procedure xp_cmdshell, Line 1 [Batch
Start Line 159] An error occurred during the execution of xp_cmdshell.
A call to 'CreateProcess' failed with error code: '2'.

According to Microsoft's Release Notes for SQL Server 2017 General Availability, the following are currently not available on Linux:
Database engine
Transactional replication
Merge replication
Stretch DB
Polybase
Distributed query with 3rd-party connections
System extended stored procedures (XP_CMDSHELL, etc.)
Filetable
CLR assemblies with the EXTERNAL_ACCESS or UNSAFE permission set
Buffer Pool Extension
SQL Server Agent
Subsystems: CmdExec, PowerShell, Queue Reader, SSIS, SSAS, SSRS
Alerts
Log Reader Agent
Change Data Capture
Managed Backup
High Availability
Database mirroring
Security
Extensible Key Management
AD Authentication for Linked Servers
AD Authenticatin for Availibility Groups (AGs)
Services
SQL Server Browser
SQL Server R services
StreamInsight
Analysis Services
Reporting Services
Data Quality Services
Master Data Services
Microsoft also has a list of Release notes and a list of unsupported features here.

Related

MSSQL Restoring database giving error that unable to open physical file and operating system error 0 (null), I am unable to restore this data base

I am trying to restore this database from
https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0
but getting this below error. Help on this will much more appreciated.
The following Github issue suggests that the WorldWideImporters sample database requires the FILESTREAM capability: Restore database backup onto mounted directory with FILESTREAM #122
Error: Unable to open the physical file "C:\Temp\WideWorldImporters_InMemory_Data_1" Operating system error 0: "(null)"
...
nocentino commented on 6 Jan 2021
Hi there, Filestream is not supported in SQL Server on Linux and Docker containers. Check out this link for more details - https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-editions-and-components-2019?view=sql-server-ver15#Unsupported
From your screen shot it appears that you are using SQL Server Express's LocalDB which also does not support FILESTREAM, ref: SQL Server Express LocalDB:
Restrictions
LocalDB cannot be managed remotely via SQL Management Studio.
LocalDB cannot be a merge replication subscriber.
LocalDB does not support FILESTREAM.
LocalDB only allows local queues for Service Broker.
An instance of LocalDB owned by the built-in accounts such as NT AUTHORITY\SYSTEM can have manageability issues due to Windows file system redirection. Instead use a normal Windows account as the owner.

Database migration MS SQL Studio 17 to Microsoft Azure SQL database

I have received the below errors while trying to migrate the MS SQL database to Azure SQL database.
Error Validating elements [Login_Name]: User:[Login_Name] has an unresolved reference to Login [AMD_Readonly]
The element User:[Login_Name] has property AuthenticationType set to a value that is not supported ij Microsoft Azure SQL Database v12.
Please guide me how to get rid from this issue.
With this given information, I suggest you to use Azure Data Migration Assistant (DMA) to detect compatibility issues that can impact database functionality in your new version of SQL Server or Azure SQL Database.
As you have given below error:
The element User:[Login_Name] has property AuthenticationType set to a
value that is not supported in Microsoft Azure SQL Database v12.
It seems like this is a feature in your source database which doesn't supported in Azure SQL Database, hence you are getting this error. To detect similar issues and recommendation, you can use DMA.
You can find the other DMA Capabilities to know more.
Check for SQL Server Compatibility Issues when Migrating to Azure using DMA

How to Clear SQL Cache

I have inherited a Network and Server environment recently. I have SQL Server 18 on one server, at the moment reports are very slow to be created, I went to the server instance and noticed that the memory has maxxed out, my logic is telling me to clear the SQL cache, however I am not sure where to go next (I am not an SQL expert) Details below,
SQL Server Management Studio 15.0.18384.0
SQL Server Management Objects (SMO) 16.100.46367.54
Microsoft Analysis Services Client Tools 15.0.19535.0
Microsoft Data Access Components (MDAC) 10.0.17763.1
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.17763
Memory Info Link below
Fortunately, SQL Server provides us with the undocumented stored procedures to do the job.
To clear the cache, run the set of following commands as below:
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS

How do I run script remotely on an Azure database without reliance on network reliability

I am connecting to and running queries on an Azure database (S4) which I connect to through SQL Server Management studio on my Windows 10 laptop. I have a complicated query I am running that gives me an select output after about 5 hours but since the database is so large any network problem causes me to get a transport error and lose any output I would have gotten.
if this happened with an on-premises database I would simply put the query in a SQL Server Agent job. But when connecting to an azure database instance I don't see any sql server agent in the Azure instance for me to add a query to.
I would like to be able to run a long running query remotely on a SQL Server Azure database without being dependent on stable network connection
Put those queries on a stored procedure and then use Azure Automation to schedule the execution of the stored procedure. In this StackOverflow thread I show step-by-step how to schedule execution of a stored procedure on Azure SQL Database using Azure Automation.
Also an Azure VM jump box in the same region as your database is commonly used for stuff like this.

How to migrate a database that uses master db stored procedures to Azure?

We have a sql2k8 database that uses sp_xml_preparedocument, a master db system extended stored procedure, that needs to go to Azure. The migration tools (SSMS2016 wizard) give a validation error: SQL71501 that [dbo].[sp_xml_preparedocument] is a missing reference, when validating the export.
I can't see any way to reference the sp so it can be migrated. Intellisense always shows an error too.
Could you first verify that your code works fine on Azure SQL when you manually execute the scripts? When I execute queries with sp_xml_preparedocument from MSDN on my Azure SQL Database it works fine.
If your code works, then it is a problem in SSMS migration assistant, so in that case you should report bug on SQL Server Connect site, with some minimized repro script, so SQL Server team can fix it.
Use SQL Server 2016 Enterprise with Service Pack 1 (x64) . The SP1 should support Azure DB . The 2012 version of Sql server might do iT.

Resources