BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nbonda
Obsidian | Level 7

I am trying to extract some data from Teradata but before executing code I would like to test server connection.

I want to execute code only when server is up.

Is there any SAS statement/function that can be used to test server connection in batch mode.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

How are you connecting to the server?

The LIBNAME statement will set the macro varaible SYSLIBRC which you can then check.

libname td teradata ..... ;
%if (&syslibrc) %then %do;
  %put ERROR: Could not connect to Teradata ;
%end;
%else %do;
  ... run extract code ...
%end;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

How are you connecting to the server?

The LIBNAME statement will set the macro varaible SYSLIBRC which you can then check.

libname td teradata ..... ;
%if (&syslibrc) %then %do;
  %put ERROR: Could not connect to Teradata ;
%end;
%else %do;
  ... run extract code ...
%end;
r_behata
Barite | Level 11
PROC SQL;
    
     CONNECT TO TERADATA(DATABASE=<dbname>  USER=<user> PASSWORD=<pwd>);

     CREATE TABLE temp AS
     SELECT * FROM CONNECTION TO TERADATA
     (SELECT * from <table_name> 
       sample 0
) ;
        DISCONNECT FROM TERADATA;
QUIT;

Try this if you are using SQL Pass through to teradata

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1112 views
  • 0 likes
  • 3 in conversation