반응형
/*******************************************************************************************************************
-- Title : [MSR] TSQL - sp_execute_external_script를 사용한 결과를 테이블에 넣기(insert ~ exec)
-- Reference : microsoft.com
-- Key word : microsoft r sp_execute_external_script insert exec drop proc if exists
*******************************************************************************************************************/
-- SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | -- create table create table #result ( sepal_length float , sepal_width float , petal_length float , petal_width float , species varchar(100) ); -- create proc drop proc if exists up_get_iris_dataset; go create proc up_get_iris_dataset as begin exec sp_execute_external_script @language = N'R' , @script = N'iris_data <- iris;' , @input_data_1 = N'' , @output_data_1_name = N'iris_data' with result sets (( "sepal.length" float not null , "sepal.width" float not null , "petal.length" float not null , "petal.width" float not null , "species" varchar(100) )); end; -- execute proc exec up_get_iris_dataset; -- insert ~ exec proc insert into #result exec up_get_iris_dataset; -- confirm data select * from #result; | cs |
반응형