SAS 将查询传递给 SQL 服务器

SAS pass through query to SQL Server

我在将查询传递给 SQL 服务器时遇到了一些麻烦。 OS 是 RedHat 6。在 SAS Enterprise Guide 中,我尝试执行此代码:

LIBNAME CISCO SQLSVR  DBLIBINIT='SET ANSI_NULLS, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING ON'  Datasrc="nikolaev.ivan.ru"  SCHEMA=cc  USER=vorob2  PASSWORD="{SAS002}9930904131DC199B130A9E7D42A49B5D" ;
proc sql;
insert into CISCO.vContact_I (FirstName, MidName, LastName, Address, Phone, MobilePhone, EMail, ClientCode, AddInfo, Sex, TOPIC_ID, CUSTOMER_RK, RESPONSE_TRACK_CD, QuestFlag, CriticalMessage, RegularMessage) 
     values ('N/A','AO Lomon', 'Воронин Саша', 'N/A/N/A/N/A мес/платеж N/A','N/A', 'N/A','N/A','01039602','',1,.,'01039602','26670201',0,'N/A','N/A');
quit;

但我遇到了错误:

ERROR: CLI execute error: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. : [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Statement(s) could not be prepared.

如果我尝试将 QUOTED_IDENTIFIER 选项放入 execute 语句中,它会正常工作:

proc sql;
connect to sqlsvr as sql 
(Datasrc="nikolaev.ivan.ru"  USER=vorob2  PASSWORD="{SAS002}9930914010DC199B130A9E7D42A49B5D");
execute(
SET QUOTED_IDENTIFIER ON;
insert into cc.vContact_I (FirstName, MidName, LastName, Address, Phone, MobilePhone, EMail, ClientCode, AddInfo, Sex, TOPIC_ID, CUSTOMER_RK, RESPONSE_TRACK_CD, QuestFlag, CriticalMessage, RegularMessage) 
     values ('N/A','AO Lomon', 'Воронин Саша', 'N/A/N/A/N/A мес/платеж N/A','N/A', 'N/A','N/A','01039602','',1,'','01039602','26670201',0,'N/A','N/A');
) by sql;

是否有机会使用 SQLSVR 将 QUOTED_IDENTIFIER 放入 LIBNAME STATEMENT? SAS/ACCESS ODBC 和 OLEDB 的组件未获得许可。

@Jdzel 您使用什么类型的连接?

尝试添加参数CONNECTION=SHAREDREAD
Libname 语句将类似于:

LIBNAME CISCO SQLSVR  
DBLIBINIT='SET ANSI_NULLS, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING ON' 
CONNECTION=SHAREDREAD  Datasrc="nikolaev.ivan.ru"  SCHEMA=cc  
USER=vorob2  PASSWORD="{SAS002}9930904131DC199B130A9E7D42A49B5D" ;