I am running some SQL queries via SAS using the credentials below.
The Drop Table command on it's own is fine, creating the tables is fine. I get an error with the "if object_id" line.
ERROR: Execute error: ICommand::Execute failed. : Invalid column name 'scratch.dbo.eof_tv_channel_orders_fy16_NEW_t'
I am assuming it does not like the SAS macro variable in the quotes (I tried single too).
Is there some other SQL command I could use? I could do a proc delete in SAS outside the SQL but would rather not.
%let test_flag=t;
PROC SQL;
CONNECT TO OLEDB (
CURSOR_TYPE=STATIC
BULKLOAD=YES
READ_ISOLATION_LEVEL=RU
PROPERTIES=("Integrated Security"=SSPI)
PROVIDER=SQLOLEDB.1
DATASOURCE="XXXXXXX"
);
EXECUTE (
if object_id ("scratch.dbo.eof_tv_channel_orders_fy16_NEW_&test_flag.", 'u') is not null
drop table scratch.dbo.eof_tv_channel_orders_fy16_NEW_&test_flag.
) by OLEDB;
quit;