Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDatabase

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
hi. i'm creating a Database object to connection ms sql server. i'm trying to truncate all my tables in my database. this is my code...
CDatabase* theDb= new CDatabase;
theDb->OpenEx("local=dsn");

char sqlCommand[1000];

sprintf(sqlCommand,"TRUNCATE TABLE STYLES;TRUNCATE TABLE ZONES;TRUNCATE TABLE ROBOTS;TRUNCATE TABLE POINTS;TRUNCATE TABLE GROUPS;TRUNCATE TABLE FUNCTIONS;TRUNCATE TABLE STYLE_INFO;");

theDb->SetQueryTimeout(0);
theDb->ExecuteSQL(sqlCommand);
theDb->Close();
//this works fine but when my tables get too big when i truncate it, it stalls the program i tried setting the timeout to (0) but that just cause it to crash..
help pls?
 
Have you tried to truncate one table at a time in a worker thread? This could be done by creating thread to run a loop and repopulating the sqlCommand string with an individual truncate command within that loop. Creating another thread will free the program to continue with other work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top