专家,
很好奇。有什么方法可以在任何SQL Server中执行Python脚本?
如果是这样,请给我一些参考链接
在SQL Server中执行Python脚本对此问题
,有关更多详细信息,请阅读此文档
我希望这对您有帮助!:(
我远非专家,但最近在寻找这个,因此,如果它有帮助,这是一个非常简单的T-SQL脚本,带有嵌入式Python(请注意:假设您使用机器学习服务python全部在SQL Server上设置(。
-- Stored proc which runs embedded Machine Learning Services scripts
EXEC sp_execute_external_script
-- The SQL query to be input to the Python script
@input_data_1 = N'SELECT TOP(100) [CustomerID], [JobNumber]
FROM [dbo].[Heading] ORDER BY DateDelivery DESC',
-- Variable name for the input SQL data ('InputDataSet' is the default if none)
@input_data_1_name = N'InputDataSet',
-- The language of the script
@language = N'Python',
-- Python script itself - Just imports Pandas and creates a new DataFrame with only one of the two input columns
@script = N'
import pandas as pd
OutputDataSet = pd.DataFrame(InputDataSet["CustomerID"])
'
-- Declaring SQL columns for the output (a Pandas DataFrame)
WITH RESULT SETS (
("CustomerID" INT NULL)
)