MSSQL 2017 includes Microsoft Machine Learning Services, which allows for the execution of Python and R scripts within MSSQL via sp_execute_external_script
. This is an expansion of the functionality available in MSSQL 2016, which allowed for the execution of R scripts with SQL Server R Services. Examples of how to abuse this functionality with R scripts are available elsewhere.
To execute Python code:
Machine Learning Services (In-Database)
andPython
must have been selected during installation- External scripts must be enabled
EXEC sp_configure 'external scripts enabled', 1
RECONFIGURE WITH OVERRIDE
- Restart the database server
- The user must have
EXECUTE ANY EXTERNAL SCRIPT