BookmarkSubscribeRSS Feed
Billybob73
Quartz | Level 8

Hi,

I'm facing a problem with explicit pass throughs to SQL server database.

The following code works fine :

options sastrace=',,,d' sastraceloc=saslog nostsuffix;

%let dsn = <mydatabase>;

%let authdomain = <myauthdomain>;

libname tempdb odbc dsn=&dsn. authdomain=&authdomain. connection=shared;

data test;

date = '01JAN2019'd ;

datetime = '01JAN2019:00:00'dt ;

run;

data tempdb.'#test'n;

set test;

run;

data test;

set tempdb.'#test'n;

run;

 

However when I do the following :

proc sql;

connect to odbc as test (dsn=&dsn. authdomain=&authdomain. connection=shared);

execute (

create table #datumtijd

(

datum DATE,

datumtijd DATETIME,

)

) by test;

quit;

data test;

set tempdb.'#datumtijd'n;

run;

 

I get the message :

ERROR: File TEMPDB.'#datumtijd'n.DATA does not exist.

Why is that ?

 

I would like to insert the data from '#test'n into '#datumtijd'n. Like this :

proc sql;

connect to odbc as test (dsn=&dsn. authdomain=&authdomain. connection=shared);

execute (

INSERT INTO #datumtijd

SELECT * FROM #test)

by test ;

disconnect from odbc;

quit;

 

Thanks for your help !!

Regards

BB

 

4 REPLIES 4
Reeza
Super User
I suspect that when you disconnect your temp tables are lost due to starting a new session/connection. Do you have a schema you can write to that will persist between sessions?
SASKiwi
PROC Star

Check what is happening in SQL Server Management Studio in the tempdb database.

 

What happens if you continue to use your LIBNAME database connection like so:

 

proc sql;
  connect using tempdb;
<put your passthru query here>
quit;
Billybob73
Quartz | Level 8
The temp table does not dissappear after the data step. Test keeps existing.
In the passthrough i don t use a disconnect......
SASKiwi
PROC Star

@Billybob73  - I guess your latest thread supersedes this one. Note, I've posted a question regarding your SAS version there. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 883 views
  • 0 likes
  • 3 in conversation