0

我正在尝试通过 cmd 行从 sql plus 将一些数据导出到 CSV,但不断收到此错误:

SP2-0042 unknown command "  S" - rest of line ignored. 

我像这样运行它

sqlplus user/pass@server @exportdata.sql

脚本看起来像这样

    SET UNDERLINE OFF
    SET COLSEP ,
    SET LINES 1000 PAGES 1000
    SET FEEDBACK off
    SET HEADING on
    Spool C:\NetworkThresholdTriggers\ARL1_1X.csv
    SELECT t1.BSM_NM, t1.D_DTM AS DATETIME, SUM(V_ATT_CNT) AS V_ATT_CNT, SUM(V_DRP_CALL_CNT) AS V_DRP_CALL_CNT
    FROM (SELECT BSM_NM, MAX(D_DTM) AS MAXDATETIME
    FROM DS3R_FH_1XRTT_BTS_LVL_KPI
    GROUP BY BSM_NM) t2
    INNER JOIN DS3R_FH_1XRTT_BTS_LVL_KPI t1 
    ON
    t1.BSM_NM = t2.BSM_NM                
    AND  t1.D_DTM = t2.MAXDATETIME
    AND t1.BSM_NM = 'ARL1'
    GROUP BY 
    t1.BSM_NM, t1.D_DTM
    HAVING
    CASE WHEN SUM(V_ATT_CNT) = 0 THEN 0 ELSE SUM(V_DRP_CALL_CNT)/SUM(V_ATT_CNT) END >= .01;
    Spool OFF

奇怪的是,如果我像这样登录到 sqlplus

sqlplus user/pass@server

然后粘贴代码,它可以工作。为什么它不适用于 .sql 文件?

4

1 回答 1

0

想通了,必须保存为ANSI文件而不是UNICODE

于 2013-05-21T13:21:15.233 回答