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

Hi.

 

I have a table on Teradata, and I want, from SAS, to delete all records from the table until it's empty. I know I can drop the table, but is there a way to delete all the rows but keep it as an empty table? 

 

 

proc sql;
    delete from TD.MY_TABLE;
quit;

 

 

Should something like this work? It hangs for me. I had full access to write/update/delete. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

SAS does not have a concept of "delete all rows" (also called truncate in other SQL implementations) so it is deleting each observation individually. That might take a long time on a large Teradata table.

 

Try using pass thru to Teradata so you can use Teradata syntax instead of PROC SQL syntax.

https://www.teradatapoint.com/teradata/teradata-truncate-table.htm

 

So if you already have a libref connected to teratadata, let's call it TD, then the SAS code would be:

proc sql ;
connect using td;
execute by td
(delete my_table all
);
quit;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

SAS does not have a concept of "delete all rows" (also called truncate in other SQL implementations) so it is deleting each observation individually. That might take a long time on a large Teradata table.

 

Try using pass thru to Teradata so you can use Teradata syntax instead of PROC SQL syntax.

https://www.teradatapoint.com/teradata/teradata-truncate-table.htm

 

So if you already have a libref connected to teratadata, let's call it TD, then the SAS code would be:

proc sql ;
connect using td;
execute by td
(delete my_table all
);
quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 2338 views
  • 3 likes
  • 2 in conversation