专家,
只是好奇才知道。有没有办法在任何sql server中执行python脚本?
若是,请提供一些参考链接
答案 0 :(得分:0)
答案 1 :(得分:0)
我离专家很远,但最近看起来这个,所以这里有一个非常简单的T-SQL脚本,如果它可以帮助任何人,可以使用嵌入式Python(注意:假设您在SQL Server上设置了Machine Learning Services with Python)
-- 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)
)