How to delete or truncate all transaction from table

Sometimes it's take long time when you delete record with the instruction MyTable.delete() or Delete_From My Table.

Then it is better to delete from SQL instruction.

For that you can create one class and put this method in.

static server void ClearTable(str _tablename)
{
    SqlDataDictionary   sqlDict;
    
    if(!tableName2Id(_tablename))
        return;
    sqlDict = new SqlDataDictionary() ;
    new SqlDataDictionaryPermission(methodstr(SqlDataDictionary, tableTruncate)).assert();
    sqlDict.tableTruncate(tableName2Id(_tablename),false);
    CodeAccessPermission::revertAssert();
}

then enjoy!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.