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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1343 views
  • 3 likes
  • 2 in conversation