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;

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.

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