Take the 2-minute tour ×

I want to truncate all data from table by truncate command, not by delete command. I tried given code but didn't get luck.

using (var session = OpenSession())
            using (var tx = session.BeginTransaction())
                session.CreateSQLQuery("truncate table Attendee").ExecuteUpdate();
share|improve this question

closed as off-topic by Andrew Barber Nov 6 '13 at 21:10



what was the error? –  dotjoe May 15 '12 at 14:02
Does table Attendee have indexes to other tables? Can you run truncate table Attendee in MSSQL studio? –  Rippo May 15 '12 at 14:02
Yes Attendee table has indexes to other tables. But if i used delete command or delete data manualy, it removes. So, If 'delete' command is running, then why 'truncate' command is not running. –  Gaurav Gupta May 16 '12 at 8:58
add comment

Browse other questions tagged or ask your own question.