Sas进程sql

时间:2017-06-05 13:24:22

标签: sql sql-server sas proc

我正在尝试从SQL服务器表中选择名称中都有短划线且大于32个字符。

我试过传递并引用但没有快乐。

我不太可能获得一个视图,只有读取权限。

proc sql;
    drop table poss_gw1;
    create table poss_gw1 as ( select * from cdb.'''form_Garden_waste_service_AF-Form-59fb9946-0f6e-4cd9-‌​9b30-82fc5d96ec71'''‌​n as agg);
quit;

proc sql;
    connect to odbc(dsn=FirmstepReporting user=myname pwd=mypwd);
    Create table work.tmp_gw as select * from connection to odbc (select * from "'form_Garden_waste_service_AF-Form-59fb9946-0f6e-4cd9-9b30-‌​82fc5d96ec71'"n);
    disconnect from odbc;
quit;

任何人都有任何想法?

1 个答案:

答案 0 :(得分:2)

您需要在pass thru code中使用SQL Server语法。

create table work.tmp_gw as 
select * from connection to odbc 
(select * 
 from "form_Garden_waste_service_AF-Form-59fb9946-0f6e-4cd9-9b30-‌​82fc5d96ec71"
); 

如果您的变量名也对SAS无效,那么您还需要在pass thru代码中更改名称。

create table work.tmp_gw as 
select * from connection to odbc 
(select id
      , "invalid-name" as valid_name 
 from "form_Garden_waste_service_AF-Form-59fb9946-0f6e-4cd9-9b30-‌​82fc5d96ec71"
);