WITH RESULT SETS()AS OBJECT(表)的正确语法

时间:2017-05-16 08:58:26

标签: sql-server tsql

使用sp_execute_external_script时,我无法找到WITH RESULT SETS选项的正确语法,以将结果集存储在表中。

以下是doc

中给出的语法
sp_execute_external_script   
@language = N'language' ,   
@script = N'script',  

@input_data_1 = ] 'input_data_1'   
[ , @input_data_1_name = ] N'input_data_1_name' ]   
[ , @output_data_1_name = 'output_data_1_name' ]  
[ , @parallel = 0 | 1 ]  
[ , @params = ] N'@parameter_name data_type [ OUT | OUTPUT ] [ ,...n ]'  
[ , @parameter1 = ] 'value1' [ OUT | OUTPUT ] [ ,...n ]  
[ WITH <execute_option> ]  
[;]  

<execute_option>::=  
{  
  { RESULT SETS UNDEFINED }   
| { RESULT SETS NONE }   
| { RESULT SETS ( <result_sets_definition> ) }  
}  

<result_sets_definition> ::=   
{  
    (  
     { column_name   
       data_type   
     [ COLLATE collation_name ]   
     [ NULL | NOT NULL ] }  
     [,...n ]  
)  
| AS OBJECT   
    [ db_name . [ schema_name ] . | schema_name . ]   
    {table_name | view_name | table_valued_function_name }  
| AS TYPE [ schema_name.]table_type_name  
} 

但是我在写

时遇到错误
WITH RESULT SETS 
((
    [IDENTIFIANT] VARCHAR(50),
    [DATE] date,
    [CORPUS] NVARCHAR(MAX)
) AS OBJECT [databasename].[dbo].[tablename]);

1 个答案:

答案 0 :(得分:0)

Jeroen Mostert给出的答案:您可以使用WITH RESULT SETS((...))或WITH RESULT SETS(AS OBJECT ...),但不能同时使用两者。