我想在SAS中写一个passthrough查询,但我不想带回结果,我想将结果存储在Teradata中。
在Teradata SQL中,我可以做到
create table db.table2 as (select
column1,
column2,
count(*) as cnt
from
db.table1
group by
column1, column2
having cnt = 1) with data primary index(column1, column2)
)
在SAS中,只有传递查询的示例会将一些结果返回到SAS中。在这种情况下,我只想使用SAS在Teradata上创建一个表而不离开SAS接口(我可以在Teradata Studio Express中执行此操作),但它会破坏工作流程。
如何在不返回结果的情况下进行“传递”?以下似乎不起作用。我想做什么是正确的?
PROC SQL;
CONNECT TO TERADATA(user="user" password="pw" server ="Teradata.something.somehwere");
drop table teradata.sometable ;
DISCONNECT FROM TERADATA;
QUIT;
答案 0 :(得分:4)
您需要EXEC
声明:
PROC SQL;
CONNECT TO TERADATA(user="user"
password="pw"
server ="Teradata.something.somehwere");
EXEC( ) BY TERADATA;
EXEC( Commit ) BY TERADATA; /* this is needed if the above statement modifies the database in anyway) */
drop table teradataserver.sometable ;
DISCONNECT FROM TERADATA;
QUIT;
在括号内,您可以插入将在数据库上运行的Teradata SQL语句,并将结果保存在数据库中。所以,完整的:
PROC SQL;
CONNECT TO TERADATA(user="user"
password="pw"
server ="Teradata.something.somehwere");
EXEC(
create table db.table2 as
(
select
column1,
column2,
count(*) as cnt
from
db.table1
group by
column1, column2
having cnt = 1
) with data primary index(column1, column)
) BY TERADATA;
DISCONNECT FROM TERADATA;
QUIT;
有关信息,BY
部分指定处理语句的DB,如果我们连接到SQL过程中的多个DB,例如
PROC SQL;
CONNECT TO TERADATA AS T1 (...);
CONNECT TO TERADATA AS T2 (...);
EXEC(...) by T1;
EXEC(...) by T2;
DISCONNECT FROM T1;
DISCONNECT FROM T2;
QUIT;