3 回答
TA贡献1793条经验 获得超6个赞
declare @num1 int = 10, @num2 int=5, @thesum int;
EXEC sp_execute_external_script @language=N'Python',
@script = N'
import pandas as pd
ser = pd.Series([6, 7, 6 * 7])
df = pd.DataFrame(ser)
OutputDataSet = df
a=x123
b=y345
sumresult=a+b
',
@output_data_1_name = N'OutputDataSet',
@params = N'@x123 int, @y345 int, @sumresult int output',
@x123= @num1, @y345=@num2, @sumresult = @thesum output
WITH RESULT SETS((Answer int));
select @thesum;
TA贡献2021条经验 获得超8个赞
@output_data_1
不是 的命名参数sp_execute_external_script
。
句法:
sp_execute_external_script @language = N'language', @script = N'script' [ , @input_data_1 = N'input_data_1' ] [ , @input_data_1_name = N'input_data_1_name' ] [ , @input_data_1_order_by_columns = N'input_data_1_order_by_columns' ] [ , @input_data_1_partition_by_columns = N'input_data_1_partition_by_columns' ] [ , @output_data_1_name = N'output_data_1_name' ] [ , @parallel = 0 | 1 ] [ , @params = N'@parameter_name data_type [ OUT | OUTPUT ] [ ,...n ]' ] [ , @parameter1 = 'value1' [ OUT | OUTPUT ] [ ,...n ] ]
TA贡献1942条经验 获得超3个赞
他们俩都有帮助!我必须转换为 JSON。还要查看 orient 参数的各种选项。
DECLARE @answers NVARCHAR(MAX)
EXEC sp_execute_external_script @language=N'Python',
@script = N'
import pandas as pd
ser = pd.Series([6, 7, 6 * 7])
df = pd.DataFrame(ser).to_json(orient=''values'')',
@params = N'@df NVARCHAR(MAX) OUTPUT',
@df = @answers OUTPUT
--
PRINT @answers
添加回答
举报