Andrew Whittam
Andrew Whittam

Reputation: 59

Sas process sql

I am trying to select from a SQL server table that both has dashes in the name and is greater than 32 characters.

I have tried pass through and quotes but no joy.

It's very unlikely that I could get a view produced and only have read access.

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;

Any one have any ideas?

Upvotes: 0

Views: 51

Answers (1)

Tom
Tom

Reputation: 51621

You need to use SQL Server syntax in the pass thru code.

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

If your variable names are also not valid for SAS then you will need to change the name in the pass thru code also.

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"
); 

Upvotes: 2

Related Questions